Combo box index change with Access DB
Error:
An unhandled exception of type 'System.InvalidCastException' occurred in system.data.dll
Additional information: Object must implement IConvertible.
Code:
Private Sub cbProdName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbProdName.SelectedIndexChanged
'displays product info based on the item selected
If cbProdName.SelectedIndex <> -1 Then
'clear ProdInfo data set
dsProdInfoObj.Clear()
'look up data based on combo box selection
daProdInfo.SelectCommand.Parameters("ProductID").Value = cbProdName.SelectedValue
'fill the data set
daProdInfo.Fill(dsProdInfoObj)
'convert data
'txtProdID.Text = CInt(txtProdID.Text)
'txtUnitPrice.Text = CDec(txtUnitPrice.Text)
'txtUnitStock.Text = CInt(txtUnitStock.Text)
End If
End Sub
With these lines:
'convert data
txtProdID.Text = CInt(txtProdID.Text)
txtUnitPrice.Text = CDec(txtUnitPrice.Text)
txtUnitStock.Text = CInt(txtUnitStock.Text)
I get this error:
An unhandled exception of type 'System.InvalidCastException' occurred in system.data.dll
Additional information: Object must implement IConvertible.

