Not really my code.
I take it from the LR and only set the three TextFields. For the record, here is the code in both PushButtons:
PushButton 1: ProcessDB
[code]Sub Pressed() Handles Pressed
// 1. Create a Data Base File
Var db As New SQLiteDatabase
db.DatabaseFile = New FolderItem(“MyDB.sqlite”)
Try
db.CreateDatabase
// proceed with database operations…
db.Connect
// App.DB is a SQLite database
Var sql As String
sql = "CREATE TABLE Team (ID INTEGER NOT NULL, Name TEXT, Coach TEXT, City TEXT, PRIMARY KEY(ID));"
Try
db.ExecuteSQL(sql)
MessageBox("Team table created successfully.")
Catch error As DatabaseException
MessageBox("DB Error: " + error.Message)
End Try
Catch error As DatabaseException
MessageBox("Database not created. Error: " + error.Message)
Return
End Try
End Sub[/code]
PushButton 2: AddRecord
[code]Sub Pressed() Handles Pressed
// Add the TextFields contents as a new Record
Var db As New SQLiteDatabase
db.DatabaseFile = New FolderItem(“MyDB.sqlite”)
Try
db.Connect
db.ExecuteSQL(“BEGIN TRANSACTION;”) // Was:db.SQLExecute
db.ExecuteSQL ("INSERT INTO Team (Name,Coach,City) VALUES " _
+ “('” + TextField1.Value + “', '” + TextField2.Value + “', '” + TextField3.Value + “');”) // Was:db.SQLExecute and three strings *
db.CommitTransaction
Catch error As DatabaseException
MessageBox("Error: " + error.Message)
db.RollbackTransaction
End Try
End Sub[/code]
- The Table name was different in the LR example.
You can compare with the LR: nearly a Copy/Paste.
I only wanted to know what was different with API 1. :([quote=457660:@Jay Madren]So just what ’ character are you referring to? Do you perhaps have a ’ character in the data you’re trying to insert? That would cause a problem with the way your code is written. And that brings us to the new automatic prepared statement like Sascha used. It will properly handle situations like that.[/quote]
Your guess is correct: I wanted to know what happens and set a ’ in the TextField (and use also some non ASCII characters).
This part I do not understand how it is meant to be working. And that - as I already say - was the purpose of this example.
I think I will stop this until November or December once all the frenzy will stop and come back to 2019r2 when .1 or .2 will be released.
Have a nice week end all !