SQl的存储过程
create procedure mytry
(
@name nvarchar(50),
@number nvarchar(50),
@pr nvarchar(50) output
)
As
begin --
if exists (select name from persons where name = @name)
set @pr = 'yes'
else
set @pr = 'no'
end
c# 调用部分过```
conn.Parameters.Add("@name", SqlDbType.NVarChar).Value = "Ada";
conn.Parameters.Add("@number", SqlDbType.NVarChar).Value = "0";
conn.Parameters.Add("@pr", SqlDbType.NVarChar).Value = "0";
conn.Parameters["@pr"].Direction = ParameterDirection.Output;
sqlcon.Open();
conn.ExecuteNonQuery();
//获得返回信息,显示在文本中
txt.Text = conn.Parameters["@pr"].Value.ToString();
sqlcon.Close();
最后的调试结果,就只有一个“y”
![图片说明](https://img-ask.csdn.net/upload/201911/25/1574647402_459149.png)