3
我有以下SQL存儲過程調用採用精緻小巧
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetNextNumberTest]
@NEWNUMBER varchar(100) OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SET @NEWNUMBER = 'ABC00001'
RETURN 1
END
我試圖用短小精悍的讀取NENUMBER值SQL存儲過程,這裏是我的代碼
private string GetNextNumber()
{
var dynamicParams = new DynamicParameters();
dynamicParams.Add("rval", DbType.Int32, direction: ParameterDirection.ReturnValue);
dynamicParams.Add("NEWNUMBER", DbType.String, direction: ParameterDirection.Output);
var data = db.QueryMultiple("GetNextNumberTest", dynamicParams, commandType: CommandType.StoredProcedure);
var result = dynamicParams.Get<string>("NEWNUMBER");
return result;
}
但我總是得到以下錯誤
An exception of type 'System.Data.SqlClient.SqlException' occurred in Dapper.dll but was not handled in user code
Additional information: Error converting data type varchar to int.
任何幫助,非常感謝。
非常感謝你。非常感謝你的幫助。 –