首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

没分了,问一调用存储过问的有关问题

2012-02-01 
没分了,问一调用存储过问的问题!publicintaaa(stringaname,intatype){try{conn.Open()//stringSqlStrnul

没分了,问一调用存储过问的问题!
public   int   aaa(string   aname,   int   atype)
        {
                try
                {
                        conn.Open();
                        //string   SqlStr   =   null;
                        SqlCommand   Cmd   =   conn.CreateCommand();
                        Cmd.CommandType   =   CommandType.StoredProcedure;
                        Cmd.CommandText   =   "query_xx ";
                        Cmd.Parameters.Add( "@aname ",   SqlDbType.VarChar,   50);
                        Cmd.Parameters.Add( "@atype ",   SqlDbType.Int,   4);

                        Cmd.Parameters.Add( "@aid ",   SqlDbType.Int,   4);
                        Cmd.Parameters[ "@aid "].Direction   =   ParameterDirection.Output;

                        Cmd.Parameters[ "@aname "].Value   =   aname;
                        Cmd.Parameters[ "@aname "].Value   =   atype;
                        Cmd.ExecuteNonQuery();
                        int   result   =   Convert.ToInt32(Cmd.Parameters[ "@aid "].Value);
                        return   result;
                }
                catch
                {
                        return   0;
                }
        }


执行到Cmd.ExecuteNonQuery();就没执行了,就是说Cmd.ExecuteNonQuery();还没有执行,

上面哪写错了??   呵呵

[解决办法]
Cmd.Parameters[ "@aname "].Value = aname;
Cmd.Parameters[ "@aname "].Value = atype;

有没有写错?
2个 "@aname "?

热点排行