Can you tell me how to get the result of a query created in the SQLite file itself?
Private Sub Example
Dim sqlSelect As String = "select field1, field2, field3 from mytable"
Dim rs As ResultSet = SqlLite.ExecQuery(sqlSelect)
Do While rs.NextRow
Log(rs.GetString("field1"))
Log(rs.getstirng("field2"))
Loop
rs.Close
End Sub
You misunderstood the question.Maybe I was not really understund the question...
I will go with 2 step logic...You misunderstood the question.
The query is already in the SQLite database file itself.
sql1.InitializeSQLite(my_path, "my_tags.db", False)
Dim rs As ResultSet = sql1.ExecQuery("SELECT * FROM tags")
' rs = sql1.ExecQuery("call select lds")
Have you solved the problem?Thank you RichardN and aeric!
The task is just that.
The database my_tags.db has a table named tags and a query named lds.
I can't get data from a query only.Code:sql1.InitializeSQLite(my_path, "my_tags.db", False) Dim rs As ResultSet = sql1.ExecQuery("SELECT * FROM tags") ' rs = sql1.ExecQuery("call select lds")
my_tags.db attached.
sql1.InitializeSQLite(my_path, "my_tags.db", False)
sql1.Initialize(my_path, "my_tags.db", False)
No, I haven't decided.Have you solved the problem?
I'm just testing in B4JThis code is for B4J.
Database and almost the entire project in post #7.It is always a good idea to upload a small project
Launched. Works with the table, with request - is not present. An exception occurs.Can you run this?
I don't understand what you are trying to say, may be due to lost of translation. Can you post what is the error message?Launched. Works with the table, with request - is not present. An exception occurs.
'rs = sql1.ExecQuery("SELECT * FROM tags")
rs = sql1.ExecQuery("SELECT * FROM lds")
The error occurs when:
B4X:'rs = sql1.ExecQuery("SELECT * FROM tags") rs = sql1.ExecQuery("SELECT * FROM lds")
Error occurred on line: 22 (Main)
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: lds)
at org.sqlite.DB.newSQLException(DB.java:383)
at org.sqlite.DB.newSQLException(DB.java:387)
at org.sqlite.DB.throwex(DB.java:374)
at org.sqlite.NativeDB.prepare(Native Method)
at org.sqlite.DB.prepare(DB.java:123)
at org.sqlite.PrepStmt.<init>(PrepStmt.java:42)
at org.sqlite.Conn.prepareStatement(Conn.java:404)
at org.sqlite.Conn.prepareStatement(Conn.java:399)
at org.sqlite.Conn.prepareStatement(Conn.java:383)
at anywheresoftware.b4j.objects.SQL.ExecQuery2(SQL.java:365)
at anywheresoftware.b4j.objects.SQL.ExecQuery(SQL.java:353)
at b4j.example.main._appstart(main.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
at java.lang.Thread.run(Thread.java:748)
Dim rs As ResultSet = sql1.ExecQuery("SELECT lds FROM tags")
In my database, in addition to the table, there is a query:Your database file only contains 1 table name tags.
> Executing SQL from within an Android program or even within B4J is a very slow way and painful way to learn SQL@Sergey_New
In your database 'tags' is a Table, and 'lds' is the name of a field within that table.
The error message: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: lds) tells you all you need to know. You are asking SQL to look for an object that is not there.... a table called 'lds' which is a field name not a table.
Try this:
SELECT * FROM tags alternatively,
SELECT key, family, lds FROM tags where you only need certain fields (it keeps the memory use to a minimum).
Executing SQL from within an Android program or even within B4J is a very slow way and painful way to learn SQL. I suggest you try an SQL management program as I suggested at post #5