求助.........asp.net访问存储过程
create procedure PLogin(
@name nvarchar(20),
@pwd nvarchar(20),
@count int output
)
AS
select @count=count(*) from student where stuname=@name and stuPwd=@pwd
RETURN
//////////////////////////////////////////////////////////////////////////////
//在程序中访问如下
SqlCommand cmd = new SqlCommand("PLogin", conn);
= CommandType.StoredProcedure;
cmd.Parameters.Add("@name", SqlDbType.NVarChar, 20);
cmd.Parameters["@name"].Direction = ParameterDirection.Input;
cmd.Parameters["@name"].Value = txtName.Text;
cmd.Parameters.Add("@pwd", SqlDbType.NVarChar, 20);
cmd.Parameters["@pwd"].Direction = ParameterDirection.Input;
cmd.Parameters["@pwd"].Value = txtPwd.Text;
cmd.Parameters.Add("@count", SqlDbType.Int);
cmd.Parameters["@count"].Direction = ParameterDirection.Output;
int num = (int)cmd.ExecuteScalar();//该行报错 未将对象引用设置到对象的实例