Insert Web Text Field data into Sqlite DB

You forgot to connect to the db

You are doing an insert before you connect to the database.
The second insert after the db connect is correct.

DB.InsertRecord("MasterAccount", CustomerRecord)  <-- Remove this line

If DB.Connect Then
  DB.InsertRecord("MasterAccount", CustomerRecord)
  DB.Commit

Else
  MsgBox("The database couldn't be opened. Error: " + DB.ErrorMessage)
  DB.Rollback
End If

[quote=420049:@Paul Sondervan]Else

MsgBox("The database couldn't be opened. Error: " + DB.ErrorMessage) DB.Rollback <--- Also remove this line End If[/quote]

Why Rollback if the DB is NOT connected? :slight_smile:

Thank you for the assistance.
I have removed the Insert line before the Connect but I am still not able insert the record.

[quote=420155:@Craig Wyeth]Thank you for the assistance.
I have removed the Insert line before the Connect but I am still not able insert the record.[/quote]

What Error does the DB report, please?

It does not Error. The DB.Connect is successful but the Insert does not seem to insert the record.

Thank you

what does the db.errormessage show JUST AFTER THE INSERT

DB.InsertRecord("MasterAccount", CustomerRecord) msgbox db.errormessage DB.Commit

no such table: MasterAccount

There’s your error right there. The database has no table called MasterAccount :slight_smile:

I’m clearly missing something as I created the DB with the associated Table.

https://i.postimg.cc/L6M3YcPB/Screenshot-2019-01-04-at-15-17-09.png

open the db in another sqlite manager such as “Datum” or so.

With this you can check if your changes in the xojo-sqlite-interface are commited correctly.

The IDE-inbuilt interface for sqlite isn’t alway the best choice.

I assume this error occurs during a Debug session. If so, is that database also in your Debug folder for that project? If so, does it have a MasterAccount table?

I’m actually not sure if what I said above is relevant if you have the database in the IDE itself. Not sure how that works during Debug. I only use databases that are not in the IDE.

not sure also the primary key named “ID” is a boolean field… will certainly not work. you must use an integer.

that is true, but why say cannot find MasterAccount???

I see in your picture that you have added a link to the database in the IDE.
Is the link in the IDE pointing to the same location as the location that you are using to connect to the database (DBFile)?
If not then the database you connect to doesn’t have the table that you assume it does.

Furthermore I would advise you to use SpecialFolder to get to the documents folder.

DBFile = SpecialFolder.Documents.Child("Wyzelink").Child("Wyzelink Xojo Projects?").Child("ALC.sqlite")

Thank you for your advice and assistance. It is very much appreciated.

  1. I have removed the ALC DB and MasterAccount table and recreate using DB Browser for SQLite as suggested by @Lars Lehmann
    https://i.postimg.cc/Mpj6cVZf/Screenshot-2019-01-06-at-05-47-06.png
  2. I have removed the link to the DB in the IDE and amended the ID Field to type Integer as suggested by @Ralph Alvy, @Jean-Yves Pochez and @Paul Sondervan
  3. I have amended the link to the DB (ALC.DB) to use the SpecialFolder as advised by @Paul Sondervan

Thank you

and … does it work now ?

Unfortunately not. I am still receiving the same error message.

no such table: MasterAccount