I 100% agree. This will be soon fixed. It did work in the past, I guess that the new SQLite version or Basic4ppc wrapper has broke this example for some reason.It certainly should not unexpectedly grind to a halt with a message which will mean nothing to a beginner. And you should test it before before putting it online. An example that doesn't work is a poor advertisement for your product and your production standards.
SQLCommand.CommandText = "SELECT Name FROM SQLite_Master WHERE [COLOR="Red"]'Type = 'Table'[/COLOR] AND Name = 'FileNames'"
SQLReader.Value = SQLCommand.ExecuteReader
If SQLReader.ReadNextRow = True Then
Sub CreateTableIfNotExists
'Find all the tables in this database
Command.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' AND name='t_orders'"
'instantiate reader
Reader.New1
'Fill reader
Reader.Value = Command.ExecuteReader
If Reader.ReadNextRow = False Then
' No table with this name in the database.
' Create one.
Command.CommandText = "CREATE TABLE t_orders (ID INTEGER PRIMARY KEY, Sum REAL, TableNum INTEGER," & _
"SeatNum INTEGER, Hamburger INTEGER, French INTEGER, Coke INTEGER, Water INTEGER, " & _
"isServed INTEGER, Time TEXT)"
Command.ExecuteNonQuery
Else
'Close reader anyhow
Reader.Close
End If
End Sub
As for the missing Reader.Close - fix me if I'm wrong, but the source code does not differ (in this part, there are some other minor differences) than the code provided on the tutorial itself. In both the Reader.Close is written after the ELSE statement, with the comment "Close reader":B4X:Sub CreateTableIfNotExists 'Find all the tables in this database Command.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' AND name='t_orders'" 'instantiate reader Reader.New1 'Fill reader Reader.Value = Command.ExecuteReader If Reader.ReadNextRow = False Then [COLOR="Red"]Reader.Close[/COLOR] ' No table with this name in the database. ' Create one. Command.CommandText = "CREATE TABLE t_orders (ID INTEGER PRIMARY KEY, Sum REAL, TableNum INTEGER," & _ "SeatNum INTEGER, Hamburger INTEGER, French INTEGER, Coke INTEGER, Water INTEGER, " & _ "isServed INTEGER, Time TEXT)" Command.ExecuteNonQuery Else 'Close reader anyhow Reader.Close End If End Sub
Sub CreateTableIfNotExists
'Find all the tables in this database
Command.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' AND name='t_orders'"
'instantiate reader
Reader.New1
'Fill reader
Reader.Value = Command.ExecuteReader
If Reader.ReadNextRow = False Then
[COLOR="Red"]Reader.Close[/COLOR]
' No table with this name in the database.
' Create one.
Command.CommandText = "CREATE TABLE t_orders (ID INTEGER PRIMARY KEY, Sum REAL, TableNum INTEGER," & _
"SeatNum INTEGER, Hamburger INTEGER, French INTEGER, Coke INTEGER, Water INTEGER, " & _
"isServed INTEGER, Time TEXT)"
Command.ExecuteNonQuery
End If
[COLOR="Red"]Reader.Close[/COLOR]
End Sub
I think in order to prevent these messages regardless of the regional settings you have to execute something like this on AppStart"String was not recognised as a valid DateTime".
Caravelle
DateFormat("yyyy-mm-dd")
TimeFormat("HH:mm:ss")
SQLCommand.CommandText = "SELECT Name FROM SQLite_Master WHERE Type = 'table' AND Name = 'FileNames'"
SQLReader.Value = SQLCommand.ExecuteReader
If SQLReader.ReadNextRow = True Then...
RandomCoder, please try:
B4X:SQLCommand.CommandText = "SELECT Name FROM SQLite_Master WHERE Type = 'table' AND Name = 'FileNames'" SQLReader.Value = SQLCommand.ExecuteReader If SQLReader.ReadNextRow = True Then...
and let me know, please, if it works. Note the lower case in the word "table" unlike you previous example. It works here.
Ariel
Type is only valid for a database field. Your screenshot is showing the table definitions which don't have a type.The problem is that the type field is blank as can be seen using the browser
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?