string commandGetIslemIdleri = ("EXEC GetIslemIdleri");
cmd = new SqlCommand(commandGetIslemIdleri, sqlConn);
cmd.Parameters.Add(new SqlParameter("@CARIID", 110));
using (var reader = cmd.ExecuteReader()) //error occurs here
{
while (reader.Read())
{
islemidleri.Add(reader.GetInt32(0));
}
}
以上是我正在嘗試寫入的代碼,使用參數CARIID
這是一個整數來調用以下存儲過程。當我運行代碼時發生錯誤,並說"Procedure or function 'GetIslemIdleri' expects parameter '@CARIID', which was not supplied."
,但盡我所知,從我從here讀取的例子我發送參數與此代碼cmd.Parameters.Add(new SqlParameter("@CARIID", 110));
我需要幫助,提前謝謝。將參數傳遞給c中的sql存儲過程#
ALTER PROCEDURE [dbo].[GetIslemIdleri]
@CARIID int
AS
BEGIN
SET NOCOUNT ON;
SELECT ID
FROM TBLP1ISLEM
WHERE [email protected]
END
您是否指定了cmd.CommandType = CommandType.StoredProcedure; – WorldIsRound 2011-03-23 15:45:13
我試了十次,沒有什麼改變,但謝謝。 – Bastardo 2011-03-23 15:49:04