[Gambas-user] Adding values to fields in SQLite table??
rocko
sunblaster5 at ...626...
Tue Aug 7 21:18:43 CEST 2012
Having a bit of trouble with trying to get Ganbas to add a value to a
field in a table.
I have a sqlite DB with a table named 'inventory' with field names like:
'name', 'start_date', 'end_date' and so on.
I'm trying to add values to the fields using a interface, I have a text
box to add a name to the 'name' field in the inventory table.
But I am not having any success.
I'm using Gambas version 2.21 as that is in my repo and been following
the older book "A beginners Giude to Gambas" which i think uses version
1.9 as a basis.
Here is my code for the 'connect' button:
PUBLIC SUB btnConnect_Click()
DIM $hConn AS NEW Connection
TRY $hConn.CLOSE
WITH $hConn
.Type = "sqlite"
.Host = "/home/rocko/DataBases"
.Name = "plant_trax"
END WITH
TRY $hConn.Open
IF ERROR THEN PRINT "Database cannot be opened. Error = ", Error.Text
$hConn.Close
END
This works as far as I can tell as I don't get the error.
The offending code i believe is in the btnAdd_CLICK():
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
TRY $hConn.Open
IF ERROR THEN PRINT "Database cannot be opened. Error = ", Error.Text
INC Application.Busy
$hConn.Begin
rTable = "Inventory"
rTable!name = txtName.Text
rTable.Update
$hConn.Commit
FINALLY
DEC Application.Busy
$hConn.Close
END
I was getting "Database cannot be opened. Error =Driver name missing"
So I added an "$hconn.Open".
But now the app just hangs when I click the add new btn
The database doesn't get updated.
Forgive me but I'm still learning Gambas and basic.
I had compiled a newer version of Gambas from the SVN but that was on
another laptop that got stolen last week and I just installed what ever
was in my repo (Crucnhbang) on my replacement, but I don't think thats
my problem.
More information about the User
mailing list