Hi this is my code for computing the payment of my system, But there have a problem in my codes ? Because, there have something wrong my codes, i try to fix the error but i can't, this is the error " Conversation from type 'DBNul' to type 'Integer' is not valid" how to fix this error ?

Private sub Booktotal()
    Dim booktot as Integer
    Dim subtot as Integer
    sql = *SELECT  Sum (Bookamount) FROM books*
    cmd = New OleDbCommand(sql, myconn)
    dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)

    If dr.Read = True Then
        booktot = dr(0)
        subtot += booktot 

    end if 
end sub



Old question, but here is something to look at. The error suggests that one or more records have value of Bookamount field as null. As a results, the sum() can't add the null value with integer. You should check your database...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.