Arithmetic Overflow when manipulating as400 data using vb.net 2008

25 pts.
Tags:
AS/400
VB.NET
Visual Basic
I will include the code so you can see what I am talking about at the end. I have a vb.net 2008 app that I am writing. Everything seems to go fine until I add/edit/delete a record. I am getting the following error: Arithmetic Operation resulted in an overflow. If I ignore the error everything runs as I expect it to. However, I cannot have an application with an error. To give you a better idea of what is going on, I will give an example. My app allows me to select a client and choose a product that the client offers. After choosing the product I am taken to a screen that will allow me to add/delete/edit the images and image info for that product. The data is displayed using a datagridview. At first I thought it might be a timestamp issue, but I am getting this error even when doing a simple delete. Below is the code where the error occurs.
Try
                    If conn.State = ConnectionState.Open Then
                        conn.Close()
                    End If
                    ds3.Clear()
                    conn.Open()
                    'create new command variable
                    Dim cmdDelete As New OdbcCommand
                    Dim x As Integer
                    cmdDelete = conn.CreateCommand
                    'set the command text to the sql delete statement
                    cmdDelete.CommandText = "DELETE FROM " & companyInfo & ".ORPMIMGX WHERE " & companyInfo & ".ORPMIMGX.ORIMGNAME LIKE '" & imgName.Trim() & "'"
                    'executes the delete command
                    x = cmdDelete.ExecuteNonQuery()
                    pbImage.Image = Nothing
                    'deletes the image from the server
                    IO.File.Delete(tbImageLocation.Text & imgName)
                    MsgBox("Image Deleted")
                    'reloads the datagridview with the new data
                Catch ex As Exception
                    'If there is an error above, display the error message
                    MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!")
                Finally
                    reloadDG()
                    conn.Close()
                End Try
If there is a better way for me to do this I am all ears. I just have to get this taken care off asap. I appreciate any help I can get on this. Thanks!


Software/Hardware used:
Visual Studios 2008, AS400 v7r1

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    What is the exact line of code that triggers the error ?
    70,190 pointsBadges:
    report
  • Smccoy
    The error occurs at cmdDelete.ExecuteNonQuery().
    25 pointsBadges:
    report
  • carlosdl
    The first thing I do when the execution of a dynamically constructed SQL command generates an error is to display it before executing it, so I can check if it has in fact been constructed correctly. Then I try to execute it directly against the database, to see if I get the same error that way. Have you tried something like this ?
    70,190 pointsBadges:
    report
  • Smccoy
    I ran the delete query and the insert query directly against the database. they both worked fine. I did change the delete query to delete based on ID instead of name. What is real odd is that both queries when ran in the vb app even though it throws an exception on ExecuteNonQuery() but the records are still added to database.
    25 pointsBadges:
    report
  • philpl1jb
    x = cmdDelete.ExecuteNonQuery() Your problem isn't with the right side of the statement so it must be with the left side. The spec's say that the return value is system32.integer .. a big integer. The expected return value is 1 which should clearly fit into a integer type. But perhaps the return for deleting this type is the number of bytes, this would cause an overflow of x. It doesn't look like you use the return value so you could write this as; cmdDelete.ExecuteNonQuery() Phil
    50,860 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following