Update Query not saving changes?

// Variable Declarations
Var dbRow As RowSet
Var blnTest As Boolean = False
Var strDate As String = modSysFunc.mthDate
Var strTime As String = modSysFunc.mthTime

// Code in Action!
If ( dbJHGC_Events.Connect ) = True Then
  'dbRow = modSel.mthSel_EventTracker( strVendorId, strEventId )
  dbRow = dbJHGC_Events.SelectSQL( "SELECT * FROM tblEventTracking WHERE vendorID=? AND eventID=?", strVendorId, strEventId )
  
  If( dbRow ) = Nil Then
    MsgBox "Record Set Error: " + Str(dbJHGC_Events.ErrorCode) + EndOfLine + EndOfLine + dbJHGC_Events.ErrorMessage _
    + EndOfLine + EndOfLine + "Error generated from: modUpd.mthUpd_EventTracker." )
    Exit
  Else
    Try
      dbRow.EditRow
      
      dbRow.Column("vendorID").StringValue = strVendorId
      dbRow.Column("eventID").StringValue = strEventId
      dbRow.Column("daysRequested").StringValue = strDaysReq
      dbRow.Column("attended").StringValue = strAttend
      dbRow.Column("cancelled").StringValue = strCancelled
      dbRow.Column("howCancelled").StringValue = strHowCanx
      dbRow.Column("notes").StringValue = strNotes
      dbRow.Column("whoSigned").StringValue = strStaff
      
      dbRow.SaveRow
      dbRow.Close
      blnTest = True
    Catch
      MessageBox( "Oh crap! UPDATE didn't update... Call Ian!!!" )
    End Try
  End If
  Return blnTest
ElseIf dbJHGC_Events.Error Then
  // Testing for issues in the DB tissues!
  Beep
  MsgBox "Database Error: " + Str( dbJHGC_Events.ErrorCode ) + EndOfLine + EndOfLine + dbJHGC_Events.ErrorMessage
  Exit
End If

Thing is another query similar to this seems to work fine. What they hey? I step through the code and the dbRow has values as do all the pertinent variables and there are no errors. It just dosn’t save changes…

Well… I figured it out! I am passing data that is too large for the field in the database… derp!

2 Likes

That’s the bad thing with databases, they are almost always right :wink:

So, not SQLite, then.

When it failed… did it throw an Exception, so you got your MessageBox?

RowSet.SaveRow should throw a DatabaseException if the row could not be saved.

It’s just that if it hasn’t… then this needs to be considered a bug and reported. It could be that only MySQL/MSSQL (whatever you’ve used - we still don’t know) is affected…

If it has… then why don’t you look at the Error Message? That would most likely have given you the clue because of which field it failed and why…

Something along these lines:

Try
  dbRow.EditRow
  //fill row data
  dbRow.SaveRow
Catch error As DatabaseException
  MessageBox("Oh crap! UPDATE didn't update... Call Ian!!!  Tell him the DB Error: " + error.Message + " and the DB Error Reason: " + error.Reason + " so that he can fix this.")
End Catch
3 Likes
dbJHGC_Events.Commit

I think you have to include the rowid in the SELECT statement.