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
Mayur DighePosted Jan 26, 2013, 1:17 AM
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
ahmed fahdPosted Jan 22, 2013, 2:34 AM
Jignesh TrivediPosted Jan 17, 2013, 11:44 PM
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.