Parmaeterized query was not supplied
-
martes, 02 de agosto de 2011 8:58
Can anyone help me in this issue:
The parameterized query '(@CallId int,@CallAttendedBy varchar(50),@CallOpenDate varchar(5' expects the parameter '@IssueSeverity', which was not supplied.
Here is my Code:
Dim
sql As Stringsql =
"INSERT INTO CallDB (CallID,CallAttendedBy, CallOpenDate,CallClosedDate,CallDuration,CallerName,Designation,ContactNumber,IssueMaterial,IssueDescription,IssueSeverity,IssueAssignedTo,CallRemarks,IssueStatus) VALUES(@CallId,@CallAttendedBy,@CallOpenDate,@CallClosedDate,@CallDuration,@CallerName,@Designation,@ContactNumber,@IssueMaterial,@IssueDescription,@IssueSeverity,@IssueAssignedTo,@CallRemarks,@IssueStatus)"
nonqueryCommand = New SqlCommand(sql, thisConnection)nonqueryCommand.Parameters.Add(
New SqlParameter("@CallId", SqlDbType.Int, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@CallAttendedBy", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@CallOpenDate", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@CallClosedDate", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@CallDuration", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@CallerName", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@Designation", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@ContactNumber", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@IssueMaterial", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@IssueDescription", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@IssueSeverity", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@IssueAssignedTo", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@CallRemarks", SqlDbType.VarChar, 50))nonqueryCommand.Parameters.Add(
New SqlParameter("@IssueStatus", SqlDbType.VarChar, 50))nonqueryCommand.Parameters(
"@CallId").Value = CInt(TextBox19.Text)nonqueryCommand.Parameters(
"@CallAttendedBy").Value = ComboBox9.SelectedValuenonqueryCommand.Parameters(
"@CallOpenDate").Value = DateTimePicker6.TextnonqueryCommand.Parameters(
"@CallClosedDate").Value = DateTimePicker7.TextnonqueryCommand.Parameters(
"@CallDuration").Value = TextBox18.TextnonqueryCommand.Parameters(
"@CallerName").Value = TextBox22.TextnonqueryCommand.Parameters(
"@Designation").Value = TextBox21.TextnonqueryCommand.Parameters(
"@ContactNumber").Value = TextBox20.TextnonqueryCommand.Parameters(
"@IssueMaterial").Value = ComboBox11.SelectedValuenonqueryCommand.Parameters(
"@IssueDescription").Value = ComboBox10.SelectedValuenonqueryCommand.Parameters(
"@IssueSeverity").Value = ComboBox7.SelectedValuenonqueryCommand.Parameters(
"@IssueAssignedTo").Value = ComboBox6.SelectedValuenonqueryCommand.Parameters(
"@CallRemarks").Value = TextBox17.TextnonqueryCommand.Parameters("@IssueStatus").Value = ComboBox8.SelectedValue
nonqueryCommand.ExecuteNonQuery()
MessageBox.Show("Record saved")
Catch ex As SqlException
MessageBox.Show(
"Error accured")Finally
thisConnection.Close()
End Try
Regards!
Judin
Todas las respuestas
-
viernes, 05 de agosto de 2011 8:44Moderador
You will get the parameter not supplied error if the value supplied is null. Check that your parameters value, for example "DateTiimePicker6.Text" is the right format that to be passed to the coordinate variable. In my situation, the DateTimePicker.Text is something like "Friday, August 05, 2011
", Is this the text you want to pass to the CallOpenDate variable?
Helen Zhou [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marcado como respuesta Helen ZhouModerator jueves, 18 de agosto de 2011 2:50
-
miércoles, 10 de agosto de 2011 10:38
S u r correct,
Please advice if some alternate code so tha i can change it accordingly.
Also please help me in the below issue too:
Calculate the time duration between 2 datetimepicker in the format "HH:MM:SS"
1st datetimepicker - start time
2nd datetimpicker - end time
Regards!
Judin
Regards! Judin -
jueves, 18 de agosto de 2011 2:29Moderador
You need to set the the type for Parameter "CallOpenDate" to, not SqlDbType.VarChar if you want to value this parameter to "DateTiimePicker6.Value.Date", not "DateTimePicker.Text". So change it like this (same with "CallClosedDate" parameter) :
nonqueryCommand.Parameters.Add(New SqlParameter("@CallOpenDate",SqlDbType.DateTime).Value = DateTiimePicker6.Value.Date;
For more types with command parameters about SqlDbType, please visit the MSDN link: Configuring Parameters and Parameter Data Types (ADO.NET)
Helen Zhou [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Marcado como respuesta Helen ZhouModerator jueves, 18 de agosto de 2011 2:50
-
jueves, 18 de agosto de 2011 2:50Moderador
And as for your second question that calculate the time duration between two DateTimePicker, You can
1 textBox1.Text = dateTimePicker5.Value.Substract(dateTimePicker6.Value).Days.ToString();
2 Use timespan like this:
dateTimePicker6.CustomFormat = "yyyy,MM,dd";
dateTimePicker7.CustomFormat = "yyyy,MM,dd";DateTime d1 = new DateTime(long.Parse(dateTimePicker6.Text));
DateTime d2 = new DateTime(long.Parse(dateTimePicker7.Text));
TimeSpan d = d2.Subtract(d1);More about how to calculate timespan, please refer to : http://msdn.microsoft.com/en-us/library/system.timespan.subtract.aspx and similar thread: http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/94d58fde-d9a5-4e46-acb6-012df41dc396
Helen Zhou [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.


