I had created a stored procedure "DeleteRow" that can receive a parameter "recordID" from the calling function, however, I received a error msg "Procedure or function deleteRow has too many arguments specified." when run the C# code.
My code is showing below
----------- -------
thisConnection.Open();
SqlParameter param = DeleteRow.Parameters.Add("@.recordI D", SqlDbType.Int, 4);
param.Value = key;
SqlDataReader reader = DeleteRow.ExecuteReader(CommandBeh avior.CloseConnection) //program stop after runing this line
The stored procedure code which is showing below:
--------------------
CREATE PROCEDURE dbo.deleteRow @.recordID INT AS DELETE FROM ShoppingCart WHERE RecordID = @.recordID
Can anyone give me some ideal why this happen.
Thank alot.
wing
"@.recordI D",
see the whitespace
|||You should be using ExecuteNonQuery. ExecuteReader is designed to return data, not update.
|||omg, I've overlooked that. :$
You can also use an ExecuteScalar. In contract to ExecuteNonQuery, itwill get the first field of the first row. Usefull when using a returnvalue in a stored procedure...
No comments:
Post a Comment