Android Question SQLiteLight2 Example

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

Getting nowhere with SQL example.
Started Example2, threw up error when I tried to ADD an entry. I had entered the three inputs it said I had entered four.

I retried in Debug, same message with the B4A line number. A mobile screen shot attatched.
The error log is below:

All I've done so far is update the Manifest to version 26 and added #BridgeLogger: True.

Any clues on how to get the example to work.

Thanks in advance Roger



Logger connected to: LGE LG-H990
--------- beginning of main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
--------- beginning of system
http://1.5.stub/
http://1.7.stub/
http://1.9.stub/
** Activity (main) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = true **
** Activity (edit) Resume **
edit_addentry (java line: 401)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1106)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at b4a.sqlitelight2.edit._addentry(edit.java:401)
at b4a.sqlitelight2.edit._btnadd_click(edit.java:423)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
edit_addentry (java line: 401)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1106)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at b4a.sqlitelight2.edit._addentry(edit.java:401)
at b4a.sqlitelight2.edit._btnadd_click(edit.java:423)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = true **
** Activity (edit) Resume **
edit_addentry (java line: 401)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1106)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at b4a.sqlitelight2.edit._addentry(edit.java:401)
at b4a.sqlitelight2.edit._btnadd_click(edit.java:423)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
** Activity (edit) Pause, UserClosed = false **
** Activity (edit) Resume **
** Activity (edit) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = true **
** Activity (edit) Resume **
edit_addentry (java line: 401)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1106)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at b4a.sqlitelight2.edit._addentry(edit.java:401)
at b4a.sqlitelight2.edit._btnadd_click(edit.java:423)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
** Activity (edit) Pause, UserClosed = false **
** Activity (edit) Resume **
** Activity (edit) Pause, UserClosed = false **
** Activity (edit) Resume **
** Activity (edit) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = true **
** Activity (edit) Resume **
edit_addentry (B4A line: 75)
Main.SQL1.ExecNonQuery2(Query, Array As String(e
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1106)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at b4a.sqlitelight2.edit._addentry(edit.java:452)
at b4a.sqlitelight2.edit._btnadd_click(edit.java:492)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
http://0.5.stub/
** Activity (main) Pause, UserClosed = false **
** Activity (filter) Create, isFirst = true **
** Activity (filter) Resume **
** Activity (filter) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = true **
** Activity (edit) Resume **
edit_addentry (B4A line: 75)
Main.SQL1.ExecNonQuery2(Query, Array As String(e
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1106)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at b4a.sqlitelight2.edit._addentry(edit.java:452)
at b4a.sqlitelight2.edit._btnadd_click(edit.java:492)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
** Activity (edit) Pause, UserClosed = false **
** Activity (edit) Resume **
** Activity (edit) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
http://1.11.stub/
** Activity (main) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = true **
** Activity (edit) Resume **
edit_addentry (java line: 401)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1106)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at b4a.sqlitelight2.edit._addentry(edit.java:401)
at b4a.sqlitelight2.edit._btnadd_click(edit.java:423)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
** Activity (edit) Pause, UserClosed = false **
** Activity (edit) Resume **
** Activity (edit) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = true **
** Activity (edit) Resume **
edit_addentry (B4A line: 75)
Main.SQL1.ExecNonQuery2(Query, Array As String(e
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1106)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at b4a.sqlitelight2.edit._addentry(edit.java:452)
at b4a.sqlitelight2.edit._btnadd_click(edit.java:492)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = true **
** Activity (edit) Resume **
edit_addentry (B4A line: 75)
Main.SQL1.ExecNonQuery2(Query, Array As String(e
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1106)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at b4a.sqlitelight2.edit._addentry(edit.java:452)
at b4a.sqlitelight2.edit._btnadd_click(edit.java:492)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6274)
at android.view.View$PerformClick.run(View.java:24859)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
** Activity (edit) Pause, UserClosed = false **
** Activity (edit) Resume **
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
** Activity (edit) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = false **
** Activity (edit) Resume **
** Activity (edit) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = false **
** Activity (edit) Resume **
** Activity (edit) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (edit) Create, isFirst = false **
** Activity (edit) Resume **
android.database.sqlite.SQLiteException: table persons has 3 columns but 4 values were supplied (code 1): , while compiling: INSERT INTO persons VALUES (NULL, ?, ?, ?)
** Activity (edit) Pause, UserClosed = false **
** Activity (edit) Resume **
** Activity (edit) Pause, UserClosed = false **
 

Attachments

  • Error2.jpg
    Error2.jpg
    18.8 KB · Views: 358

mangojack

Expert
Licensed User
Longtime User
The reason for this error is your Insert statement is supplying an Array of 4 Values to be inserted ...
but the Persons table has only 3 columns / fields.

I had entered the three inputs it said I had entered four.
The Insert statement does contain 4 Values .. the first Value 'NULL' is still treated as a value/parameter . On Inserts ... when Null is passed as the ID value , the table ID will auto increase by 1.

Ps: In the original example Persons table does have 4 fields (persons.db in Assets file) .. You have not altered the db in any way ?
If you still have an issue it might be better to upload your example to make it easier to solve your problem.
 
Last edited:
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Thanks Mangojack,

The only changes I have made are what I said in the original post.

The code is from Klaus' booklet on SQL {Tutorial} which I hoped would get me started.
I am guessing that when you say 4 values you refer to "Query = "INSERT INTO persons VALUES (NULL, ?, ?, ?)"".
I have no idea of the number of fields as the reason I loaded this example was to start on SQL.

I have attached the file.

Regards Roger
 

Attachments

  • SQLiteLight2.zip
    18 KB · Views: 363
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I did have an error at first (read only db issue) but it was caused by extra unneeded lines in the starter Service_Create sub.

Edit the Starter Service Sub to read as follows ...
B4X:
Sub Service_Create
    'File.Delete(File.DirInternal, "persons.db") ' only for testing, removes the database
 
    'check if the database already exists
    If File.Exists(File.DirInternal, "persons.db") = False Then
        'copy the default DB
        File.Copy(File.DirAssets, "persons.db", File.DirInternal, "persons.db")
        'and initialize it
        SQL1.Initialize(File.DirInternal, "persons.db", True)
    Else
        'db does exist ... so just initialize it
        SQL1.Initialize(File.DirInternal, "persons.db", True)
    End If
End Sub

After this change your uploaded example worked fine ..

ps: If you do have an issue ... I would run the File.Delete line once , then comment it back out.

pps: Download this db utility to look inside the persons db (project folder / files ) .... https://sqlitebrowser.org/
 
Last edited:
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Klaus said he needed to update the booklet when he answered a query on SQL1 earlier this month.
I think it is time for me to delete the complete folder of source code and start again.
I've been trying to get in to this for the past few months but life keeps getting in the way. Fresh start tomorrow.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
There were several bugs in the program.
Below an updated version.
Sorry for the trouble :).

The program in your post #3 is an old one.
It's not the program shiped with the B4X SQLite Database Booklet.
 

Attachments

  • SQLiteLight2.zip
    17.4 KB · Views: 386
Upvote 0
Top