this is the procedure
ALTER PROCEDURE dbo.Attendance_Table_Update
@State_ nvarchar(50),@emp_id int,@Day_Dat date
AS
UPDATE Attendance_Table
SET State_ = @State_
WHERE (Emp_ID = @emp_id) AND (Day_Dat = @Day_Dat)
this is the usage of it
command.CommandType = CommandType.StoredProcedure
command.CommandText = "attendance_table_update"
command.Connection = con
command.Parameters.AddWithValue("@emp_id", b._emp_num)
command.Parameters.AddWithValue("@state_", b._emp_situation)
command.Parameters.AddWithValue("@day_dat", b._day_date)
con.Close()
con.Open()
command.ExecuteNonQuery()
Return True
con.Close()
'End Try
Return True
Loading

Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 17, 2013, 6:44 PM EST
Generally this error due to mismatch between Parameter of SP and parameter pass from code.
kindly check no of parameter.
Also try to default value of parameter.
example
Alter PROCEDURE dbo.Attendance_Table_Update
(@State_ nvarchar(50) = null,
@emp_id int = 0,
@Day_Dat date)
AS
UPDATE Attendance_Table
SET State_ = @State_
WHERE (Emp_ID = @emp_id) AND (Day_Dat = @Day_Dat)
hope this will help you.
ahmed fahd57 reputationPosted Jan 21, 2013, 9:34 PM EST
Mayur DigheRank #1,078 · 1.8K reputationPosted Jan 25, 2013, 8:17 PM EST
You can do it ......buddy....
But tell me first........"WHY are you Closing the Connection before Open it..?"
(see the red text below)
command.CommandType = CommandType.StoredProcedure
command.CommandText = "attendance_table_update"
command.Connection = con
command.Parameters.AddWithValue("@emp_id", b._emp_num)
command.Parameters.AddWithValue("@state_", b._emp_situation)
command.Parameters.AddWithValue("@day_dat", b._day_date)
con.Close()
con.Open()
command.ExecuteNonQuery()
Return True
con.Close()
'End Try
Return True