sam
sam

Reputation: 2606

Passing time from DateTimePicker to database parameters

I have form with DateTimePicker and it is format Time and I want to pass time from DateTimePicker to database parameters as shown below but I am getting error message that says at line of cmd.ExecuteNonQuery();

{"Procedure or function 'PROC_REGISTER_SESSION' expects parameter '@START_TIME', which was not supplied."}

I set breakpoint and checked all parameters and they are filled with data also test message box are filled with data

cmd.Parameters.Add(new SqlParameter("@StartTime", SqlDbType.Time)).Value = DTP_StartTime.Value.TimeOfDay;

Upvotes: 0

Views: 68

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460108

The error is pretty self-explaining:

{"Procedure or function 'PROC_REGISTER_SESSION' expects parameter '@START_TIME', which was not supplied."}

You pass a parameter as @StartTime not @START_TIME.

So this should fix (at least one) error:

cmd.Parameters.Add(new SqlParameter("@START_TIME", SqlDbType.Time)).Value = DTP_StartTime.Value.TimeOfDay;

Upvotes: 2

Related Questions