Results 1 to 4 of 4

Thread: A casting problem [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    A casting problem [RESOLVED]

    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
    ----------------------------------------------------------------------

    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
    the red line is where the error is thrown. cboBookD.selectedvalue is an integer. so what the prob????
    Last edited by angelica; Jun 7th, 2008 at 07:57 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width