Hello,
I am a newby to Xojo.
I am attempting to take Text Field data inputted from a Web Page and insert this into a database with the following code which is not correct.
Any assistance will be greatly appreciated.
Thank you and regards
Craig
Dim DBFile as FolderItem
DBFile = Volume(0).Child(“Users”).Child(“craigwyeth”). Child(“Documents”).Child(“Wyzelink”).Child(“Wyzelink Xojo Projects?”).Child(“ALC.sqlite”)
DB = New SQLiteDatabase
DB.DatabaseFile = DBFile
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=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]
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.
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.
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
I have amended the link to the DB (ALC.DB) to use the SpecialFolder as advised by @Paul Sondervan