当前位置: 编程技术>.net/c#/asp.net
c#获取存储过程返回值示例分享
来源: 互联网 发布时间:2014-10-26
本文导语: 存储过程: 代码如下:CREATE PROCEDURE [dbo].[Proc_GetInfo] @ywdm varchar(10), @value varchar(20) output AS begin set @value=Select top 1 createt From table Where ywdm=@ywdm end C#获取存储过程返回值: 代码如下:var db = DatabaseFactory.CreateDatabase(...
存储过程:
代码如下:
CREATE PROCEDURE [dbo].[Proc_GetInfo]
@ywdm varchar(10),
@value varchar(20) output
AS
begin
set @value=Select top 1 createt From table Where ywdm=@ywdm
end
C#获取存储过程返回值:
代码如下:
var db = DatabaseFactory.CreateDatabase();
var cmd = db.GetStoredProcCommand("Proc_GetInfo");
db.AddInParameter(cmd, "ywdm", DbType.String, mYzm.Ywdm);
db.AddOutParameter(cmd, "@value", DbType.String, 20);
db.ExecuteNonQuery(cmd);
return cmd.Parameters["@value"].Value.ToString();