Hey,
I have a compilation problem here and I cant figure it out. Can some one please pinpoint my mistake??
Error:
System.InvalidCastException was unhandled by user code
Message="Conversion from type 'DataRowView' to type 'Integer' is not valid."
Many thanks
----------------------------------------------------------------------
the red line is where the error is thrown. cboBookD.selectedvalue is an integer. so what the prob????Code:Private Sub CurrentBalanceShowD() Dim checkBook As Integer checkBook = cboBookD.SelectedValue Dim cmd As SqlCommand Try MyConn.Open() 'opening the connection cmd = New SqlCommand("Select stockBalance from tb_bookbalance where bookFID = '" & checkBook & "'", MyConn) 'executing the command and assigning it to connection txtcurrentD.Text = Convert.ToString(cmd.ExecuteScalar()) 'displaying the data from the table MyConn.Close() Catch ex As Exception MsgBox(ex.Message) MyConn.Close() End Try End Sub




Reply With Quote