SQL Parameters through C# won't work
Hi there, i'm new here, as you may see heh.
Anyways, i have a problem passing parameters to an SQL stored procedure.
Im still new to SQL, especially to Stored procedures and parameters, so it might be a stupid question.
This is the stored procedure:
CREATE PROCEDURE checkBooking
AS
DECLARE @ScheduleID varchar(50)
DECLARE @ScreenColumn int
DECLARE @ScreenRow int
Select * from tblBooking where BookingScheduleID = @ScheduleID AND BookingScreenRow = @ScreenRow AND BookingScreenColumn = @ScreenColumn
This is supposed to accept 3 parameters and return all the data back to the user.
When i try to input the parameters through C# i always get this error:
'Procedure checkBooking has no parameters and arguments were supplied.'
I tried it in two ways but i still get this error
This is the first attempt in C#:
comm.CommandText = "checkBooking";
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.AddWithValue("@ScheduleID", selectedScheduleID);
comm.Parameters.AddWithValue("@ScreenColumn", column);
comm.Parameters.AddWithValue("@ScreenRow", row);
This is the second:
comm.Parameters.Add("@ScheduleID", SqlDbType.VarChar);
comm.Parameters[0].Value = selectedScheduleID;
comm.Parameters[0].Direction = ParameterDirection.Input;
comm.Parameters.Add("@ScreenColumn", SqlDbType.Int);
comm.Parameters[1].Value = column;
comm.Parameters[1].Direction = ParameterDirection.Input;
comm.Parameters.Add("@ScreenRow", SqlDbType.Int);
comm.Parameters[2].Value = row;
comm.Parameters[2].Direction = ParameterDirection.Input;
Am i doing something wrong with the way i pass the parameters? or perhaps the sql is just wrong?
Please help, Regards and thanks.