关于C#存储结构中的output的用法

来源:百度知道 编辑:UC知道 时间:2024/05/20 18:33:11
我做了个就是output 搞不懂 看看你可以帮忙不 SqlCommand sqlcomm = new SqlCommand(); sqlcomm.Connection = sqlconn;
string str = "select @name=[name] from [user] where accountno= @accountno";
SqlCommand cmd = new SqlCommand(str,sqlconn);
sqlcomm.Parameters.Add("@name", SqlDbType.VarChar, 20);
sqlcomm.Parameters["@name"].Direction = ParameterDirection.Output;
//this.label14.Text = sqlcomm.Parameters["@name"].Value.ToString();
斜杠的是有错的

ParameterDirection.Output一般用于返回存储过程执行后的返回值,并通过SqlCommand.Parameters属性取到对应的设置了output的参数的值,该值即为存储过程的返回值。

你那句说有错的代码,在执行了sql语句后可能会成功。

sqlcomm.Parameters["@name"].Direction = ParameterDirection.Output;
这句话的意思是["@name"] 是用来接收 存储过程 中的 返回值..