A
Angelina
Hi,
I am running a stored procedure when the user selects an
item from a combobox (combobox1). This stored procuedure
gets values based on what was just chosen by the user in
combobox1 and enters these values in combobox2.
However i keep encountering the following error message
which i do not know how to resolve. Combobox2 does not
get populated due to this error....
Specified cast is not valid.
here is my code....
'Display the caravan length based on the caravan name
selected.
Dim Cn As New SqlConnection("initial
catalog=TestCaraDBmsde;integrated security=SSPI;persist
security info=False;workstation id=USER;packet size=4096")
Dim cmdLength As New SqlCommand("SPSelLengths", Cn)
cmdLength.CommandType =
CommandType.StoredProcedure
'declare the parameters
cmdLength.Parameters.Add("@CaraName",
SqlDbType.Char, 50)
'now set the values
cmdLength.Parameters("@CaraName").Value =
CBoxDisCaraNames.SelectedItem
CBoxCaraLength.Items.Clear()
CBoxCaraLength.Text = ""
Try
Cn.Open()
Dim reader3 As SqlDataReader
reader3 = cmdLength.ExecuteReader()
While reader3.Read
CBoxCaraLength.Items.Add
(reader3.GetSqlString(0))
End While
Catch ex As Exception
MsgBox(ex.Message)
Finally
Cn.Close()
End Try
End Sub
can anyone help me resolve this?
I am running a stored procedure when the user selects an
item from a combobox (combobox1). This stored procuedure
gets values based on what was just chosen by the user in
combobox1 and enters these values in combobox2.
However i keep encountering the following error message
which i do not know how to resolve. Combobox2 does not
get populated due to this error....
Specified cast is not valid.
here is my code....
'Display the caravan length based on the caravan name
selected.
Dim Cn As New SqlConnection("initial
catalog=TestCaraDBmsde;integrated security=SSPI;persist
security info=False;workstation id=USER;packet size=4096")
Dim cmdLength As New SqlCommand("SPSelLengths", Cn)
cmdLength.CommandType =
CommandType.StoredProcedure
'declare the parameters
cmdLength.Parameters.Add("@CaraName",
SqlDbType.Char, 50)
'now set the values
cmdLength.Parameters("@CaraName").Value =
CBoxDisCaraNames.SelectedItem
CBoxCaraLength.Items.Clear()
CBoxCaraLength.Text = ""
Try
Cn.Open()
Dim reader3 As SqlDataReader
reader3 = cmdLength.ExecuteReader()
While reader3.Read
CBoxCaraLength.Items.Add
(reader3.GetSqlString(0))
End While
Catch ex As Exception
MsgBox(ex.Message)
Finally
Cn.Close()
End Try
End Sub
can anyone help me resolve this?