我如何發送三個參數到存儲過程在sql中?傳遞參數到存儲過程在C#
這是我的錯誤:過程或函數GetIslemIdleri指定的參數太多。
這是我的存儲過程:
CREATE PROCEDURE GetIslemDetayIdleri
@islemId int,
@dovizTanim nvarchar(10),
@yapilanIslemTuru nvarchar(20)
AS
BEGIN
SET NOCOUNT ON;
SELECT ([t0].[TOPLAMTUTAR]) + ([t0].[KDVTUTAR]) AS [value]
FROM [dbo].[TBLP1ISLEMDETAY] AS [t0]
INNER JOIN [dbo].[TBLP1ISLEM] AS [t1] ON [t1].[ID] = [t0].[ISLEM_ID]
WHERE ([t0].[ISLEM_ID] = @islemId) AND
([t0].[FIYATBIRIM] = @dovizTanim) AND
([t1].[YAPILANISLEM] = @yapilanIslemTuru) AND
([t0].[KDVDAHILMI] = 0)
END
這裏是我的代碼:
decimal kurToplamQuery = 0;
string connString = System.Configuration.ConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(connString);
sqlConn.Open();
SqlCommand cmd;
cmd = new SqlCommand("GetIslemIdleri", sqlConn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@islemId", SqlDbType.Int)).Value = islemId;
cmd.Parameters.Add(new SqlParameter("@dovizTanim", SqlDbType.NVarChar)).Value = dovizTanim;
cmd.Parameters.Add(new SqlParameter("@yapilanIslemTuru", SqlDbType.NVarChar)).Value = yapilanIslemTipi;
using (var reader = cmd.ExecuteReader())*//error occurs here*
{
while (reader.Read())
{
kurToplamQuery = reader.GetDecimal(0);
}
}
sqlConn.Close();
return kurToplamQuery;
感謝您的幫助。
那是你不調用一個發佈存儲過程的問題?他們有不同的名字。 – 2011-03-24 13:27:08
該死的,是的,謝謝 – Bastardo 2011-03-24 13:28:33