Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2004
    Posts
    21

    Unanswered: No error message for failed update statement

    I am adding records without any problems rulling out syntax and keyword errors. I've checked the records, which all match up with the database records.

    ExecuteNonQuery of type OleDbCommand returns 0 but i dont get an error message

    Any clues as to why no error message is returned

  2. #2
    Join Date
    Jun 2004
    Location
    Terrapin Nation
    Posts
    205
    Try setting the warnings to true.

    docmd.setwarnings true

  3. #3
    Join Date
    Mar 2004
    Posts
    21
    How do you do that.
    I'm using .NET and have the error messages appearing in explorer already. Is there something extra.

  4. #4
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim cmd As New OleDb.OleDbCommand("update a set name = ""newName"" where id = 1", Me.OleDbConnection1)
            Try
                MsgBox(cmd.ExecuteNonQuery)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  5. #5
    Join Date
    Mar 2004
    Posts
    21
    Thanks for that. I tryed that but their was no error caught in the try catch. Could their be some other way of checking. This is puzzling me. I am using the same code for other update statements and they work perfectly

  6. #6
    Join Date
    Mar 2004
    Posts
    21
    As a side I'm designing in c# as well

  7. #7
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Your SQL query may not update any data rows and as such the query has not failed.
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  8. #8
    Join Date
    Mar 2004
    Posts
    21
    Quote Originally Posted by r123456
    Your SQL query may not update any data rows and as such the query has not failed.
    I think your right, but I can't understand how this would happen. The update statement updates only 1 row using a unique ID. I checked the ID being used and it exists in the database. Why would the row not be updated.

    ------------------Here's the udate statement----------------------
    string sSQL = "UPDATE stats SET grade1=@grade1, grade2=@grade2, conditions=@conditions WHERE statsId=@statsId";

    cCommand.Parameters.Add("@grade1", OleDbType.Numeric).Value = grade1;
    cCommand.Parameters.Add("@grade2", OleDbType.Numeric).Value = grade2;
    cCommand.Parameters.Add("@conditions", OleDbType.VarChar).Value = Conditions;
    cCommand.Parameters.Add("@statsId", OleDbType.Numeric).Value = statsId;

    ------------------------------------------------------------------------

Posting Permissions

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