我的存储过程:
create proc uplognmessgetpass1
@name char(20) ,@pass char(9) output
as
begin
set @pass= (select password from tbllognmess where lognname=@name)
end
这是主要的语句块
SqlConnection myconnection = new SqlConnection("data source=.;initial catalog=dail_affair;integrated security=sspi");
myconnection.Open();
myconnection.InfoMessage += new SqlInfoMessageEventHandler(myconnection_InfoMessage);
SqlCommand mycommand = new SqlCommand(" uplognmessgetpass", myconnection);
mycommand.CommandType = CommandType.StoredProcedure;
SqlParameter myparameter1 = new SqlParameter("@name", SqlDbType.Char);
myparameter1.Value = tblogn.Text.ToString();
mycommand.Parameters.Add(myparameter1);
SqlParameter myparameter = new SqlParameter("@password", SqlDbType.Char, 9);
myparameter.Direction = ParameterDirection.ReturnValue;
int count= mycommand.ExecuteNonQuery();-----------报错找不到存储过程 ????
string nn = Convert.ToString(myparameter.Value);
DataSet myset = new DataSet();
SqlDataAdapter myda = new SqlDataAdapter(mycommand);
myda.Fill(myset);
if (nn == "")
{
MessageBox.Show("该用户名不存在");
}
else
{
MessageBox.Show(nn.ToString());
}
create proc uplognmessgetpass1
@name char(20) ,@pass char(9) output
as
begin
set @pass= (select password from tbllognmess where lognname=@name)
end
这是主要的语句块
SqlConnection myconnection = new SqlConnection("data source=.;initial catalog=dail_affair;integrated security=sspi");
myconnection.Open();
myconnection.InfoMessage += new SqlInfoMessageEventHandler(myconnection_InfoMessage);
SqlCommand mycommand = new SqlCommand(" uplognmessgetpass", myconnection);
mycommand.CommandType = CommandType.StoredProcedure;
SqlParameter myparameter1 = new SqlParameter("@name", SqlDbType.Char);
myparameter1.Value = tblogn.Text.ToString();
mycommand.Parameters.Add(myparameter1);
SqlParameter myparameter = new SqlParameter("@password", SqlDbType.Char, 9);
myparameter.Direction = ParameterDirection.ReturnValue;
int count= mycommand.ExecuteNonQuery();-----------报错找不到存储过程 ????
string nn = Convert.ToString(myparameter.Value);
DataSet myset = new DataSet();
SqlDataAdapter myda = new SqlDataAdapter(mycommand);
myda.Fill(myset);
if (nn == "")
{
MessageBox.Show("该用户名不存在");
}
else
{
MessageBox.Show(nn.ToString());
}
SqlCommand mycommand = new SqlCommand(" uplognmessgetpass", myconnection); 大哥,名字怎么错了!! (" uplognmessgetpass", ..)最好也不带空格,好习惯!
但是把空格删除之后 出现了这样的错误
过程 'uplognmessgetpass' 需要参数 '@pass',但未提供该参数。
改为 myparameter.Direction = ParameterDirection.Output;