Android Question Hopefully not a stupid question...

CarlH2016

Member
Licensed User
Ok, coming over from VB6 to VB.net and now joining the B4a community (hello to you all), I have come a cropper and its probably something stupid.

Ok, I have my main module, an additional module with some declarations.

My main module calls OpenConnection and then calls CreateDB sub.

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SQL1 As SQL
End Sub

Sub OpenConnection
SQL1.Initialize(File.DirDefaultExternal, "Wedman.db", True)
End Sub

sub CreateDB
dim SQLStr as string

SQLStr = "CREATE TABLE [Clients] ("
SQLStr = SQLStr & "[ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT"
SQLStr = SQLStr & ",[Surname] TEXT NULL)"
SQL1.BeginTransaction
SQL1.ExecQuery(SQLStr)
SQL1.TransactionSuccessful
SQL1.EndTransaction

SQL1.BeginTransaction
SQLStr = "CREATE INDEX IX_INDEXID ON [Clients] ([ID])"
SQL1.ExecNonQuery(SQLStr)
SQL1.TransactionSuccessful
SQL1.EndTransaction
end sub


I know that my SQL code is ok as I have the same code running in a vb.net app.
I get no exception on creating the table, but when I try to create the index (or even just do an INSERT) I get an error of table "Clients" does not exist.

Please point out the blindingly obvious to me, thanks :)

Carl
 

mangojack

Well-Known Member
Licensed User
Longtime User
Firstly , use code tags when posting code .. easier to read ... [code] insert code here .. [/code]

SQL1.ExecQuery(SQLStr) Should be ... SQL1.ExecNonQuery(SQLStr)

also .. I am far from a sql expert , but it is the first time I have seen inclusion of square brackets in sql sentences .. although it does not error ,
you might know better as to the reason for inclusion.
 
Last edited:
Upvote 0

CarlH2016

Member
Licensed User
Firstly , use code tags when posting code .. easier to read ... [code] insert code here .. [/code]

SQL1.ExecQuery(SQLStr) Should be ... SQL1.ExecNonQuery(SQLStr)

also .. I am far from a sql expert , but it is the first time I have seen inclusion of square brackets in sql sentences .. although it does not error ,
you might know better as to the reason for inclusion.
:D it was a stupid question - thanks and something I just did not spot. (y) code tags most useful too, cheers (y)
 
Upvote 0
Top