C# 獲取 存儲過程 返回值,
C#獲取存儲過程的返回值,這一方法,總是容易忘,今天給貼出來,以方便下次使用
存儲過程:
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();