我想获取存储过程的输出到一个函数,但与我的代码我总是得到一个错误,告诉输出参数没有指定。你能帮忙吗?错误获取存储过程的输出
的代码是在这里.....
public int UserAuthentication(String username, String password)
{
SqlConnection conn = new SqlConnection("Data Source=...\\..; Initial Catalog=CUSTOMER360;User ID=sa;password=******");
SqlCommand command = new SqlCommand("sp_Campaign_UserAuthentication", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@login_id", SqlDbType.VarChar, 50, "loginid"));
command.Parameters.Add(new SqlParameter("@password",
SqlDbType.VarChar,50,
"password"));
SqlParameter ret = command.Parameters.Add(" @result", SqlDbType.Int);
ret.Direction = ParameterDirection.ReturnValue;
command.Parameters["@login_id"].Value = username;
command.Parameters["@password"].Value = password;
conn.Open();
command.ExecuteNonQuery();
conn.Close();
return (int)ret.Value;
}
我假设你发布的sa用户密码是一个虚拟字符串? :-) – 2010-08-26 09:48:44