Hello,
I'm testing the code but something strange is happening.
I have my db with a table called tblSetting and a single row. I'm trying to use this code
SQL.Initialize(File.DirInternal, "Data.db", True)
'Load initial setting
Dim m As Map
m = DBUtils.ExecuteMap(SQL, "SELECT * FROM tblSetting", Null)
If m <> Null Then
lblLabel1.Text = m.Get("Field1")
lblLabel2.Text = m.Get("Field2")
End If
but I got this error:
** Activity (main) Create, isFirst = true **
Error occurred on line: 0 (dbutils)
android.database.sqlite.SQLiteException: no such table: tblSetting (code 1): , while compiling: SELECT * FROM tblSetting
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:167)
at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:155)
at b4a.example.dbutils._executemap(dbutils.java:39)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at b4a.example.main.afterFirstLayout(main.java:98)
at b4a.example.main.access$100(main.java:16)
at b4a.example.main$WaitForLayout.run(main.java:76)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
But something more strange is happening when I use this code
'Create the students table which holds data about each student.
Dim m As Map
m.Initialize
m.Put("Id", DBUtils.DB_TEXT)
m.Put("First Name", DBUtils.DB_TEXT)
m.Put("Last Name", DBUtils.DB_TEXT)
m.Put("Birthday", DBUtils.DB_INTEGER)
DBUtils.CreateTable(SQL, "Students", m, "Id")
The app run fine but no table is created.
What's wrong with this.
Please help.