B4J and SqLite

Mvula

Member
Licensed User
Longtime User
Hi,

I have a table "mixingstation.db" in the files folder

It consists of 2 tables as shown SqLiteStructure.jpg

my code is - the complete source is in "First1.zip"

Sub Process_Globals
Private fx As JFX
Private MainForm As Form

Private PbShowTables As Button
Private PbReadTrail As Button

Dim Cursor As ResultSet
Dim SQL1 As SQL

End Sub

Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Logo") 'Load the layout file.
MainForm.Show

SQL1.InitializeSQLite(File.DirApp, "mixingstation.db", True)

'see if the database exists
If File.Exists(File.DirApp,"mixingstation.db") Then
Log("mixingstation.db exists")
Else
Log("mixingstation.db does NOT exist")
End If

End Sub
Sub PbReadTrail_Action
'get the trail data
Cursor = SQL1.ExecQuery("SELECT * FROM Trail")
'gives this error
'java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: Trail)

Cursor.Close

End Sub
Sub PbShowTables_Action
'http://www.basic4ppc.com/b4j/help/jsql.html


'get the tables
Cursor = SQL1.ExecQuery("SELECT name FROM sqlite_master WHERE type = 'table'")
'see if there are any tables
If Cursor.NextRow Then
Log ("There are tables")
Else
Log("There are NO tables")
End If
'see if there are any columns
Log("There is " & Cursor.ColumnCount & " column")
Log("title of first column is " & Cursor.GetColumnName(0))

Cursor.Close

End Sub

when pressing on "Read trail",
this error shows
Program started.

mixingstation.db exists

main._pbreadtrail_action (java line: 70)

java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: Trail)




It appears I am reading the data base, but can not read the tables.

Please tell me what I am doing wrong

Thank you
 

Attachments

  • SqLiteStructure.jpg
    SqLiteStructure.jpg
    96.9 KB · Views: 193
  • First1.zip
    1.5 KB · Views: 206
  • SqLiteStructure.jpg
    SqLiteStructure.jpg
    96.9 KB · Views: 194

Mvula

Member
Licensed User
Longtime User
Every thing now works.

I put the database into "Files" folder.
it should be in "Objects" folder.
my apologies for being so stupid
 
Upvote 0
Top