没分了,问一调用存储过问的问题!
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 "?