Hello, I have in my Computer SQL Express 2005. I use a ODBC Connection in Windows for see the data in Xojo.
When make a consult in the database all work fine. the connection is fine and I can update the listbox in XOJO.
Now I have a text Box and after I lost the Focus I make the connection but the system do not make any changes in my SQL Express (Using a ODBC Connection)
I try to use the SQLExecute(“BEGIN TRANSATION”) and the db.commit but still not work.
If db.Connect Then
//proceed with database operations
db.SQLExecute(“BEGIN TRANSATION”)
sql = “SELECT * FROM CorteDiario”
rs = db.SQLSelect(sql)
if rs = Nil then
MsgBox("NIL")
end If
rs.Edit
rs.field("AjusteLlevarChar").StringValue=trim(PollosLlevar_TxtBox.text)
rs.Update
db.SQLExecute ("UPDATE CorteDiario set AjusteLlevarChar = '" + PollosLlevar_TxtBox.text +"'")
db.Commit
Thanks, I make the change and add db.SQLExecute(“END TRANSATION”) but still not working maybe is corrupt the database. But I can see the value of the database in one ListBox but still not update the SQLExpress 2005 with the value of my text box.
How do you know???
A SQL error does not cause an error in the Xojo code.
Instead, it sets the database error property.
So: Please check the error state of your database.
and TRANSATION is not a word
Try this:
db.SQLExecute ("UPDATE CorteDiario set AjusteLlevarChar = 'TEST')
If db.Error Then
MsgBox("DB Error: " + db.ErrorMessage)
Else
MsgBox("Should have updated")
End If
If dbupdate.Connect Then
//proceed with database operations
dbupdate.SQLExecute(“BEGIN TRANSATION”)
sqlupdate = “SELECT * FROM CorteDiario”
rsupdate = dbupdate.SQLSelect(sqlupdate)
if rsupdate = Nil then
MsgBox("NILLL")
end If
rsupdate.Edit
rsupdate.field("AjusteLlevarChar").StringValue=trim(PollosLlevar_TxtBox.text)
rsupdate.Update
dbupdate.SQLExecute("END TRANSATION")
dbupdate.SQLExecute("BEGIN TRANSATION")
dbupdate.SQLExecute ("UPDATE CorteDiario set AjusteLlevarChar = 'TEST'")
dbupdate.Commit
dbupdate.SQLExecute("END TRANSATION")
If dbupdate.Error Then
MsgBox("DB Error: " + dbupdate.ErrorMessage)
Else
MsgBox("Should have updated")
End If
Else
MsgBox("Error: " + dbupdate.ErrorMessage)
End If