Hi Jim,
Knightlite wrote:Hi Klaus,
you obviously did not take a look at UPDATE example in the "SQLite Sampler.rev" stack,
where you can see a working example of the UPDATE syntax.
Well, I actually did check this sample out and I found it difficult to follow. I would also say, its not exactly a "working example" since the app crashes after you try to update a record.
Sorry, if the stack does not work for you, but I meant the SYNTAX that you should look at.
Knightlite wrote:For me, it is also difficult to learn from an example that uses a table, when my app is using a form layout. It is more difficult for me to follow.
These are just WORDS!
A table is a part of a database file where you save our data in, so you ARE in fact dealing with a table, no matter how you call your layout!
And the entries in a table are called columns of fields
Example:
Code: Select all
TABLE: addresses
Columns/fields:
id
firstname
name
city
zipcode
etc...
Knightlite wrote:A good example would be a single textbox connected to a database field. Make a change in the text box, click an update button and the change is made. That is a good example ...simple and directly to the point.
Well create this example and we will create the UDPATE part together!
Knightlite wrote:Hint: "revdb_execute" is a function!
...
put "UPDATE Questions SET XX = '" & lblX & "' WHERE _id='" & txtID & "'" into tSQLQuery
put revdb_execute(gConID,tSQL) into tResult
## Now check tResult, it should be a number = the number of records that have been updated, so it should be 1 in your case.
...
If I am supposed to copy the code above and put it into the app, that does not work either.
Come on Jim, you are of course NOT supposed to copy and paste this little snippet into your app and hope it will work!?
You should look at the snytax and try to understand what's going on and modify it to your needs (e.g. enter YOUR connection ID and variables names!
Knightlite wrote:What is "gConID"?
When you connect to a database (with "revopendatabase(...)" you get a connction ID and you need to provide this ID
with every database command so LiveCode knows what database you are working with, even if you only work with ONE database.
In my example "gConID" IS this ID.
Knightlite wrote:
How am I suppose to "Check tResult"???
What about:
Code: Select all
...
if tResult is not a number then
answer "an error has occured"
exit HANDLERNAME
end if
...
Knightlite wrote:You say I should forget about RealBasic. Maybe so, but it is 2 simple lines of code to save data there. In Visual Basic it is 1 line of code. So I don't know what the super secret code is for updating databases in LiveCode, when every single line of code I have seen in every single example does not work for me. Sorry I still don't get it.
Well obviously XBasic supplies a build-in database functionality with non-verbise syntax, which makes it easy to deal with databases.
But Livecode does not, it is more "do it yourself" in this respect, so please get used to it
Best
Klaus