Discussion:
Adding values to fields in SQLite table??
(too old to reply)
rocko
2012-08-07 19:18:43 UTC
Permalink
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.
M. Cs.
2012-08-07 21:09:54 UTC
Permalink
I use to add fields like this:
$hConn.Begin
$hConn.Exec("INSERT INTO mytable VALUES(&1,&2,..&N)",var1,var2,...varN)
$hConn.Commit

And I use Begin and Commit only for the large amount of insertions.
Csaba
Post by rocko
Having a bit of trouble with trying to get Ganbas to add a value to a
field in a table.
'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.
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.
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.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
rocko
2012-08-07 22:09:55 UTC
Permalink
Ok I tried this:
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(name)", txtName.Text)
$hConn.Commit

Without success.
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO mytable VALUES(&1,&2,..&N)",var1,var2,...varN)
$hConn.Commit
And I use Begin and Commit only for the large amount of insertions.
Csaba
Post by rocko
Having a bit of trouble with trying to get Ganbas to add a value to a
field in a table.
'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.
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.
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.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Emil Lenngren
2012-08-07 22:31:07 UTC
Permalink
Try

$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(&1)", txtName.Text)
$hConn.Commit

Do you only have one column in that table?
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(name)", txtName.Text)
$hConn.Commit
Without success.
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO mytable VALUES(&1,&2,..&N)",var1,var2,...varN)
$hConn.Commit
And I use Begin and Commit only for the large amount of insertions.
Csaba
Post by rocko
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
'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.
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.
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.
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
rocko
2012-08-07 22:46:05 UTC
Permalink
No, there are several.
I justed wanted to test it with the first column to see if it works,
which it doesn't.

Tried your suggestion:
$hConn.Exec("INSERT INTO inventory VALUES($1)", txtName.Text)

Values are still not inserting.
Post by rocko
Try
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(&1)", txtName.Text)
$hConn.Commit
Do you only have one column in that table?
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(name)", txtName.Text)
$hConn.Commit
Without success.
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO mytable VALUES(&1,&2,..&N)",var1,var2,...varN)
$hConn.Commit
And I use Begin and Commit only for the large amount of insertions.
Csaba
Post by rocko
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
'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.
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.
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.
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Olivier Cruilles
2012-08-07 22:53:48 UTC
Permalink
Hello,
Post by rocko
$hConn.Exec("INSERT INTO inventory VALUES($1)", txtName.Text)
I think it's wrong because you write this one: VALUES($1) and it's VALUES(&1)

Cordialement,

Olivier Cruilles
Post by rocko
No, there are several.
I justed wanted to test it with the first column to see if it works,
which it doesn't.
$hConn.Exec("INSERT INTO inventory VALUES($1)", txtName.Text)
Values are still not inserting.
Post by rocko
Try
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(&1)", txtName.Text)
$hConn.Commit
Do you only have one column in that table?
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(name)", txtName.Text)
$hConn.Commit
Without success.
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO mytable VALUES(&1,&2,..&N)",var1,var2,...varN)
$hConn.Commit
And I use Begin and Commit only for the large amount of insertions.
Csaba
Post by rocko
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
'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.
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.
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.
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
rocko
2012-08-07 23:02:09 UTC
Permalink
Oh yes '&' not '$', that was a typo.

In my code it's '&'.
Still can't get this to work.

Here is my full code:

PUBLIC SUB btnConnect_Click()

'DIM sName AS String
DIM $hConn AS NEW Connection


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


END

PUBLIC SUB btnAdd_Click()

DIM $hConn AS NEW Connection
'DIM $Value AS String

$hConn.Open

'TRY $hConn.Open
'IF ERROR THEN PRINT "Database cannot be opened. Error = ", Error.Text

$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(&1)", txtName.Text)
$hConn.Commit

FINALLY
$hConn.Close


END
Post by Olivier Cruilles
Hello,
Post by rocko
$hConn.Exec("INSERT INTO inventory VALUES($1)", txtName.Text)
I think it's wrong because you write this one: VALUES($1) and it's VALUES(&1)
Cordialement,
Olivier Cruilles
Post by rocko
No, there are several.
I justed wanted to test it with the first column to see if it works,
which it doesn't.
$hConn.Exec("INSERT INTO inventory VALUES($1)", txtName.Text)
Values are still not inserting.
Post by rocko
Try
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(&1)", txtName.Text)
$hConn.Commit
Do you only have one column in that table?
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(name)", txtName.Text)
$hConn.Commit
Without success.
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO mytable VALUES(&1,&2,..&N)",var1,var2,...varN)
$hConn.Commit
And I use Begin and Commit only for the large amount of insertions.
Csaba
Post by rocko
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
'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.
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.
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.
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Emil Lenngren
2012-08-07 23:08:59 UTC
Permalink
Then you have to specify what column you want to insert to.
Syntax: http://www.w3schools.com/sql/sql_insert.asp

The &1, &2 ... system used by gambas is to provide correct escaping and to
prevent sql injections.
Post by rocko
No, there are several.
I justed wanted to test it with the first column to see if it works,
which it doesn't.
$hConn.Exec("INSERT INTO inventory VALUES($1)", txtName.Text)
Values are still not inserting.
Post by rocko
Try
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(&1)", txtName.Text)
$hConn.Commit
Do you only have one column in that table?
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(name)", txtName.Text)
$hConn.Commit
Without success.
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO mytable
VALUES(&1,&2,..&N)",var1,var2,...varN)
Post by rocko
Post by rocko
Post by rocko
$hConn.Commit
And I use Begin and Commit only for the large amount of insertions.
Csaba
Post by rocko
Having a bit of trouble with trying to get Ganbas to add a value
to a
Post by rocko
Post by rocko
Post by rocko
Post by rocko
field in a table.
I have a sqlite DB with a table named 'inventory' with field names
'name', 'start_date', 'end_date' and so on.
I'm trying to add values to the fields using a interface, I have a
text
Post by rocko
Post by rocko
Post by rocko
Post by rocko
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
Post by rocko
Post by rocko
Post by rocko
Post by rocko
the older book "A beginners Giude to Gambas" which i think uses
version
Post by rocko
Post by rocko
Post by rocko
Post by rocko
1.9 as a basis.
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
Post by rocko
Post by rocko
Post by rocko
Post by rocko
$hConn.Close
END
This works as far as I can tell as I don't get the error.
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
Post by rocko
Post by rocko
Post by rocko
Post by rocko
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"
Post by rocko
Post by rocko
Post by rocko
Post by rocko
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
Post by rocko
Post by rocko
Post by rocko
Post by rocko
another laptop that got stolen last week and I just installed what
ever
Post by rocko
Post by rocko
Post by rocko
Post by rocko
was in my repo (Crucnhbang) on my replacement, but I don't think
thats
Post by rocko
Post by rocko
Post by rocko
Post by rocko
my problem.
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
rocko
2012-08-07 23:25:00 UTC
Permalink
No, that doesn't work either:

$hConn.Exec("INSERT INTO inventory VALUES(id, name)", 1, txtName.Text)
Post by Emil Lenngren
Then you have to specify what column you want to insert to.
Syntax: http://www.w3schools.com/sql/sql_insert.asp
The &1, &2 ... system used by gambas is to provide correct escaping and to
prevent sql injections.
Post by rocko
No, there are several.
I justed wanted to test it with the first column to see if it works,
which it doesn't.
$hConn.Exec("INSERT INTO inventory VALUES($1)", txtName.Text)
Values are still not inserting.
Post by rocko
Try
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(&1)", txtName.Text)
$hConn.Commit
Do you only have one column in that table?
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO inventory VALUES(name)", txtName.Text)
$hConn.Commit
Without success.
Post by rocko
$hConn.Begin
$hConn.Exec("INSERT INTO mytable
VALUES(&1,&2,..&N)",var1,var2,...varN)
Post by rocko
Post by rocko
Post by rocko
$hConn.Commit
And I use Begin and Commit only for the large amount of insertions.
Csaba
Post by rocko
Having a bit of trouble with trying to get Ganbas to add a value
to a
Post by rocko
Post by rocko
Post by rocko
Post by rocko
field in a table.
I have a sqlite DB with a table named 'inventory' with field names
'name', 'start_date', 'end_date' and so on.
I'm trying to add values to the fields using a interface, I have a
text
Post by rocko
Post by rocko
Post by rocko
Post by rocko
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
Post by rocko
Post by rocko
Post by rocko
Post by rocko
the older book "A beginners Giude to Gambas" which i think uses
version
Post by rocko
Post by rocko
Post by rocko
Post by rocko
1.9 as a basis.
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
Post by rocko
Post by rocko
Post by rocko
Post by rocko
$hConn.Close
END
This works as far as I can tell as I don't get the error.
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
Post by rocko
Post by rocko
Post by rocko
Post by rocko
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"
Post by rocko
Post by rocko
Post by rocko
Post by rocko
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
Post by rocko
Post by rocko
Post by rocko
Post by rocko
another laptop that got stolen last week and I just installed what
ever
Post by rocko
Post by rocko
Post by rocko
Post by rocko
was in my repo (Crucnhbang) on my replacement, but I don't think
thats
Post by rocko
Post by rocko
Post by rocko
Post by rocko
my problem.
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Adam Ant
2012-08-08 02:48:13 UTC
Permalink
On Wed, Aug 8, 2012 at 4:48 AM, rocko <***@gmail.com> wrote:
8<
Post by rocko
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" <---- 1
rTable!name = txtName.Text
rTable.Update <---- 2
$hConn.Commit
FINALLY
DEC Application.Busy
$hConn.Close
END
1. You are trying to set a Result to a string value. This wont work.
2. In order for gb.db to execute a database update it must have a
writeable result.

The answer is:

rTable=$hConn.Edit("Inventory",<some request to get the record you
want to update>)
IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF

The help on gb.db has plenty of examples for Result and Connection
explaining these concepts.

hth
Bruce
rocko
2012-08-08 03:13:53 UTC
Permalink
So should rTable be set as String not Result??

I've tried both and I still can't get the DB to update.

$hConn.Begin

rTable = $hConn.Edit("inventory")

IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
ENDIF

$hConn.Commit
FINALLY
$hConn.Close
Post by Adam Ant
8<
Post by rocko
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" <---- 1
rTable!name = txtName.Text
rTable.Update <---- 2
$hConn.Commit
FINALLY
DEC Application.Busy
$hConn.Close
END
1. You are trying to set a Result to a string value. This wont work.
2. In order for gb.db to execute a database update it must have a
writeable result.
rTable=$hConn.Edit("Inventory",<some request to get the record you
want to update>)
IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF
The help on gb.db has plenty of examples for Result and Connection
explaining these concepts.
hth
Bruce
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Ivan Kern
2012-08-08 05:29:16 UTC
Permalink
Fabien Bodard
2012-08-08 05:34:23 UTC
Permalink
Fabien Bodard
2012-08-08 05:29:00 UTC
Permalink
Post by Adam Ant
8<
Post by rocko
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"
<---- 1
Post by Adam Ant
Post by rocko
rTable!name = txtName.Text
rTable.Update
<---- 2
Post by Adam Ant
Post by rocko
$hConn.Commit
FINALLY
DEC Application.Busy
$hConn.Close
END
1. You are trying to set a Result to a string value. This wont work.
2. In order for gb.db to execute a database update it must have a
writeable result.
It's create
Post by Adam Ant
rTable=$hConn.create("Inventory",<some request to get the record you
want to update>)
IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF
Don't open/ close the db each time

You can use db.create too
Post by Adam Ant
The help on gb.db has plenty of examples for Result and Connection
explaining these concepts.
hth
Bruce
------------------------------------------------------------------------------
Post by Adam Ant
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Adam Ant
2012-08-08 06:03:41 UTC
Permalink
Post by Fabien Bodard
It's create
Post by Adam Ant
rTable=$hConn.create("Inventory",<some request to get the record you
want to update>)
IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF
Don't open/ close the db each time
Yes, sorry Roko (and Fabien), I forgot you were trying to ADD a new row.

So it's really
rTable=$hConn.Create("Inventory")
IF rTable.Available then
rTable!name=txtName.Text
TRY rTable.Update
IF ERROR THEN
' your update failed, possibly because of a duplicate key
ENDIF
END IF


Bruce
Fabien Bodard
2012-08-08 12:19:19 UTC
Permalink
Post by Adam Ant
Post by Fabien Bodard
It's create
Post by Adam Ant
rTable=$hConn.create("Inventory",<some request to get the record you
want to update>)
IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF
Don't open/ close the db each time
Yes, sorry Roko (and Fabien), I forgot you were trying to ADD a new row.
So it's really
rTable=$hConn.Create("Inventory")
IF rTable.Available then
rTable!name=txtName.Text
TRY rTable.Update
IF ERROR THEN
' your update failed, possibly because of a duplicate key
ENDIF
END IF
THen if you want to modify a specific line :

rTable=DB.Edit("Inventory", "id=&1", varId)

rTable!name=txtName.Text

rTable.Update
db.commit


Another thing, If your app use only one db with one connection, Open it on
start

for exemple your project begin on a module Main.module


'module
Private hCon as New Connection
Public Sub Main()
hCOn.TYpe= "sqlite"
hCon.Name="Mydb"
hCon.Host=user.home
hCon.Open

FormMyMain.Show
END


In FormMyMain do

PUblic sub Form_Close()

db.close

end




Public sub Button_Click()

dim rTable as result
rTable = db.find("mytable")
for each rTable
print rTable!name
next
end







in gambas 3 you can use ide to define connections of the project...

you can then use it in the project ... so main.module become :


Public sub Main()

Connections["MyConnection"].Open

End

If you use a mysql or other table with password.

You need to add that befor :

Conections["MyConnection"].Password="yourpassword"
Post by Adam Ant
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
--
Fabien Bodard
acidblue
2012-08-09 04:23:33 UTC
Permalink
Post by Fabien Bodard
Post by Adam Ant
Post by Fabien Bodard
It's create
Post by Adam Ant
rTable=$hConn.create("Inventory",<some request to get the record you
want to update>)
IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF
Don't open/ close the db each time
Yes, sorry Roko (and Fabien), I forgot you were trying to ADD a new row.
So it's really
rTable=$hConn.Create("Inventory")
IF rTable.Available then
rTable!name=txtName.Text
TRY rTable.Update
IF ERROR THEN
' your update failed, possibly because of a duplicate key
ENDIF
END IF
rTable=DB.Edit("Inventory", "id=&1", varId)
rTable!name=txtName.Text
rTable.Update
db.commit
Another thing, If your app use only one db with one connection, Open it on
start
for exemple your project begin on a module Main.module
'module
Private hCon as New Connection
Public Sub Main()
hCOn.TYpe= "sqlite"
hCon.Name="Mydb"
hCon.Host=user.home
hCon.Open
FormMyMain.Show
END
In FormMyMain do
PUblic sub Form_Close()
db.close
end
Public sub Button_Click()
dim rTable as result
rTable = db.find("mytable")
for each rTable
print rTable!name
next
end
in gambas 3 you can use ide to define connections of the project...
Public sub Main()
Connections["MyConnection"].Open
End
If you use a mysql or other table with password.
Conections["MyConnection"].Password="yourpassword"
Ahh I like that idea!
I 'm now using Gambas 3 ;)
When you say make module do you mean make an actual module(Right
click>>new>>module
or can i add this code to the FMain form??
CODE
Public sub Main()
Connections["MyConnection"].Open
End
Post by Adam Ant
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
--
Fabien Bodard
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
--
View this message in context: http://old.nabble.com/Adding-values-to-fields-in-SQLite-table---tp34267924p34275037.html
Sent from the gambas-user mailing list archive at Nabble.com.
acidblue
2012-08-09 04:25:27 UTC
Permalink
Ahh I like that idea!
I 'm now using Gambas 3 ;)
When you say make module do you mean make an actual module(Right
click>>new>>module)
or can i add this code to the FMain form??
CODE
Public sub Main()

Connections["MyConnection"].Open

End
Post by Fabien Bodard
Post by Adam Ant
Post by Fabien Bodard
It's create
Post by Adam Ant
rTable=$hConn.create("Inventory",<some request to get the record you
want to update>)
IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF
Don't open/ close the db each time
Yes, sorry Roko (and Fabien), I forgot you were trying to ADD a new row.
So it's really
rTable=$hConn.Create("Inventory")
IF rTable.Available then
rTable!name=txtName.Text
TRY rTable.Update
IF ERROR THEN
' your update failed, possibly because of a duplicate key
ENDIF
END IF
rTable=DB.Edit("Inventory", "id=&1", varId)
rTable!name=txtName.Text
rTable.Update
db.commit
Another thing, If your app use only one db with one connection, Open it on
start
for exemple your project begin on a module Main.module
'module
Private hCon as New Connection
Public Sub Main()
hCOn.TYpe= "sqlite"
hCon.Name="Mydb"
hCon.Host=user.home
hCon.Open
FormMyMain.Show
END
In FormMyMain do
PUblic sub Form_Close()
db.close
end
Public sub Button_Click()
dim rTable as result
rTable = db.find("mytable")
for each rTable
print rTable!name
next
end
in gambas 3 you can use ide to define connections of the project...
Public sub Main()
Connections["MyConnection"].Open
End
If you use a mysql or other table with password.
Conections["MyConnection"].Password="yourpassword"
Post by Adam Ant
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
--
Fabien Bodard
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
--
View this message in context: http://old.nabble.com/Adding-values-to-fields-in-SQLite-table---tp34267924p34275043.html
Sent from the gambas-user mailing list archive at Nabble.com.
rocko
2012-08-08 16:18:57 UTC
Permalink
Ok I've tried all the suggestions you all have made and none of them
work.
I don't get any error's printed, the table just wont update.
Should 'rtable' be AS Result or AS String??
Post by Adam Ant
Post by Fabien Bodard
It's create
Post by Adam Ant
rTable=$hConn.create("Inventory",<some request to get the record you
want to update>)
IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF
Don't open/ close the db each time
Yes, sorry Roko (and Fabien), I forgot you were trying to ADD a new row.
So it's really
rTable=$hConn.Create("Inventory")
IF rTable.Available then
rTable!name=txtName.Text
TRY rTable.Update
IF ERROR THEN
' your update failed, possibly because of a duplicate key
ENDIF
END IF
Bruce
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Fabien Bodard
2012-08-08 16:39:38 UTC
Permalink
Post by rocko
Ok I've tried all the suggestions you all have made and none of them
work.
I don't get any error's printed, the table just wont update.
Should 'rtable' be AS Result or AS String??
a result !!!

db.exec, db.create, db.edit return result !

dim rTable as result
Post by rocko
Post by Adam Ant
Post by Fabien Bodard
It's create
Post by Adam Ant
rTable=$hConn.create("Inventory",<some request to get the record you
want to update>)
IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF
Don't open/ close the db each time
Yes, sorry Roko (and Fabien), I forgot you were trying to ADD a new row.
So it's really
rTable=$hConn.Create("Inventory")
IF rTable.Available then
rTable!name=txtName.Text
TRY rTable.Update
IF ERROR THEN
' your update failed, possibly because of a duplicate key
ENDIF
END IF
Bruce
------------------------------------------------------------------------------
Post by Adam Ant
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
--
Fabien Bodard
Fabien Bodard
2012-08-08 17:01:57 UTC
Permalink
it's in french but ...

http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
rocko
2012-08-08 17:12:34 UTC
Permalink
Is there anyway to translate that??
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Fabien Bodard
2012-08-08 17:17:23 UTC
Permalink
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
--
Fabien Bodard
rocko
2012-08-08 17:42:22 UTC
Permalink
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.

CODE:
PUBLIC SUB btnAdd_Click()

DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")

IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)

ENDIF
ENDIF

$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Fabien Bodard
2012-08-08 17:48:57 UTC
Permalink
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open

End


PUBLIC SUB btnAdd_Click()

DIM rTable AS Result

rTable = DB.Create("inventory")

rTable!name = txtName.Text

TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF


DB.Commit

end

Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
--
Fabien Bodard
rocko
2012-08-08 17:54:19 UTC
Permalink
Oh yes forgot to mention I have that code in a 'connect' button.

PUBLIC SUB btnConnect_Click()

DIM $hConn AS NEW Connection
WITH $hConn
.Type = "sqlite3"
.Host = "/home/rocko/DataBases"
.Name = "my_test.sqlite"
END WITH

TRY $hConn.Open
IF ERROR THEN PRINT "Database cannot be opened. Error = ", Error.Text


END
Post by Fabien Bodard
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open
End
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = DB.Create("inventory")
rTable!name = txtName.Text
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF
DB.Commit
end
Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
rocko
2012-08-08 18:13:03 UTC
Permalink
Is it DB.Create/DB.Commit?? I was using $hConn.Create and so on.

I'm getting 'Connection Not Opened" error when click the Add_new btn.


btnConnect CODE:
PRIVATE $hConn AS Connection
PUBLIC SUB btnConnect_Click()

DIM $hConn AS NEW Connection

$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open

btnAdd CODE:

PUBLIC SUB btnAdd_Click()

DIM $hConn AS NEW Connection
DIM rTable AS Result

rTable = DB.Create("inventory")

IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)

ENDIF
ENDIF

DB.Commit

btnClose CODE:
PUBLIC SUB btnClose_Click()

$hConn.Close
FMain.Close
Post by Fabien Bodard
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open
End
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = DB.Create("inventory")
rTable!name = txtName.Text
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF
DB.Commit
end
Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Fabien Bodard
2012-08-08 18:18:21 UTC
Permalink
Do not do dim hconn...

Just say
Private $hconn as new connection
Post by rocko
Is it DB.Create/DB.Commit?? I was using $hConn.Create and so on.
I'm getting 'Connection Not Opened" error when click the Add_new btn.
PRIVATE $hConn AS Connection
PUBLIC SUB btnConnect_Click()
DIM $hConn AS NEW Connection
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
rTable = DB.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Post by Fabien Bodard
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open
End
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = DB.Create("inventory")
rTable!name = txtName.Text
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF
DB.Commit
end
Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats.
http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
rocko
2012-08-08 18:31:10 UTC
Permalink
If I do that I get an error:"$hConn already declared in FMain Class"
I already have a "Private $hConn As Connection" in the class Form.

If I put in the btnAdd sub I get:"Unexpected Private in Fmain Class"
Post by Fabien Bodard
Do not do dim hconn...
Just say
Private $hconn as new connection
Post by rocko
Is it DB.Create/DB.Commit?? I was using $hConn.Create and so on.
I'm getting 'Connection Not Opened" error when click the Add_new btn.
PRIVATE $hConn AS Connection
PUBLIC SUB btnConnect_Click()
DIM $hConn AS NEW Connection
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
rTable = DB.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Post by Fabien Bodard
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open
End
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = DB.Create("inventory")
rTable!name = txtName.Text
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF
DB.Commit
end
Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats.
http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Olivier Cruilles
2012-08-08 18:31:43 UTC
Permalink
Hello,

I think your problem is that you don't understand how to use sqlite database..

You don't renew a connection every time you want to use it.

- You open the database at the beginning of your program
- You work with it by updating it
- Before you close you program, you close the database

So to do that use it like that:

--------------------------------------------

PUBLIC $hConn AS Connection <= Error corrected

btnConnect CODE:

PUBLIC SUB btnConnect_Click()

$hConn = NEW Connection <= line added

$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open

btnAdd CODE:

PUBLIC SUB btnAdd_Click()

DIM rTable AS Result

rTable = $hConn.Create("inventory") <= Error corrected

IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)

ENDIF
ENDIF

DB.Commit

btnClose CODE:
PUBLIC SUB btnClose_Click()

$hConn.Close
FMain.Close




Cordialement,

Olivier Cruilles
Post by rocko
Is it DB.Create/DB.Commit?? I was using $hConn.Create and so on.
I'm getting 'Connection Not Opened" error when click the Add_new btn.
PRIVATE $hConn AS Connection
PUBLIC SUB btnConnect_Click()
DIM $hConn AS NEW Connection
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
rTable = DB.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Post by Fabien Bodard
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open
End
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = DB.Create("inventory")
rTable!name = txtName.Text
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF
DB.Commit
end
Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
rocko
2012-08-08 18:51:26 UTC
Permalink
Thank you sir;
You get a cookie :)
Your example works fine.

'Public' instead of 'Private' for the $hConn as Connection was the key I
believe, as was a few other small syntax related items.
The E-Book I was following(Much older version of gambas) I don't think
even mentions declaring it as either.

I'm new to sqlite and gambas, I mostly deal with perl and mysql.

Thanks to all who replied to my questions and gave examples.
The community here has always been very helpful.
Post by Olivier Cruilles
Hello,
I think your problem is that you don't understand how to use sqlite database..
You don't renew a connection every time you want to use it.
- You open the database at the beginning of your program
- You work with it by updating it
- Before you close you program, you close the database
--------------------------------------------
PUBLIC $hConn AS Connection <= Error corrected
PUBLIC SUB btnConnect_Click()
$hConn = NEW Connection <= line added
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = $hConn.Create("inventory") <= Error corrected
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Cordialement,
Olivier Cruilles
Post by rocko
Is it DB.Create/DB.Commit?? I was using $hConn.Create and so on.
I'm getting 'Connection Not Opened" error when click the Add_new btn.
PRIVATE $hConn AS Connection
PUBLIC SUB btnConnect_Click()
DIM $hConn AS NEW Connection
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
rTable = DB.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Post by Fabien Bodard
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open
End
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = DB.Create("inventory")
rTable!name = txtName.Text
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF
DB.Commit
end
Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Olivier Cruilles
2012-08-08 18:59:19 UTC
Permalink
So to be exact, it's the same mecanism for all other database.

If you declare a variable (as $hConn) in a PUBLIC SUB, the variable is local of this PUBLIC SUB
so if you want to use a variable in all a Form or Module or Class, you need to declare your variable at the beginning of this Form and not in a PUBLIC SUB

When you use a Connection object to open a database, after initialized it and opened it, the object Connection keep connected to the database, so you just need to use it.

Cordialement,

Olivier Cruilles
Post by rocko
Thank you sir;
You get a cookie :)
Your example works fine.
'Public' instead of 'Private' for the $hConn as Connection was the key I
believe, as was a few other small syntax related items.
The E-Book I was following(Much older version of gambas) I don't think
even mentions declaring it as either.
I'm new to sqlite and gambas, I mostly deal with perl and mysql.
Thanks to all who replied to my questions and gave examples.
The community here has always been very helpful.
Post by Olivier Cruilles
Hello,
I think your problem is that you don't understand how to use sqlite database..
You don't renew a connection every time you want to use it.
- You open the database at the beginning of your program
- You work with it by updating it
- Before you close you program, you close the database
--------------------------------------------
PUBLIC $hConn AS Connection <= Error corrected
PUBLIC SUB btnConnect_Click()
$hConn = NEW Connection <= line added
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = $hConn.Create("inventory") <= Error corrected
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Cordialement,
Olivier Cruilles
Post by rocko
Is it DB.Create/DB.Commit?? I was using $hConn.Create and so on.
I'm getting 'Connection Not Opened" error when click the Add_new btn.
PRIVATE $hConn AS Connection
PUBLIC SUB btnConnect_Click()
DIM $hConn AS NEW Connection
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
rTable = DB.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Post by Fabien Bodard
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open
End
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = DB.Create("inventory")
rTable!name = txtName.Text
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF
DB.Commit
end
Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
rocko
2012-08-08 22:12:43 UTC
Permalink
I have another problem. I have since updated to gambas3 btw, 3.11.

I have made another form,(FNew), basically moved the addNew procedure
to the new form.
The addNew btn on the FMain form just opens the new form(FNew.Show).

I have a "Commit" button that use the same code the addNew one did form
the FMain form.
All the code is the same.
But I'm getting an error: "Null Object in FNew"

Should I have made the new from a child of the FMain??
If so How?
BTW I wasn't sure of starting a new thread or just continue with the old
one, if I should start a new one just let me know.

The offending CODE:
rTable = $hConn.Create("inventory")

Entire CODE from FNew:

' Gambas class file

Public $hConn As Connection
Public Sub btnCommit_Click()

Dim rTable As Result

rTable = $hConn.Create("inventory")

If rTable.Available Then
rTable!name = txtName.Text
rTable!type = txtType.Text
Try rTable.Update
If Error Then
Print "Update failed"
Message.Error(ERROR.Text)

Endif
Endif

DB.Commit


End

Public Sub btnCancel_Click()

FNew.Close
Post by Olivier Cruilles
So to be exact, it's the same mecanism for all other database.
If you declare a variable (as $hConn) in a PUBLIC SUB, the variable is local of this PUBLIC SUB
so if you want to use a variable in all a Form or Module or Class, you need to declare your variable at the beginning of this Form and not in a PUBLIC SUB
When you use a Connection object to open a database, after initialized it and opened it, the object Connection keep connected to the database, so you just need to use it.
Cordialement,
Olivier Cruilles
Post by rocko
Thank you sir;
You get a cookie :)
Your example works fine.
'Public' instead of 'Private' for the $hConn as Connection was the key I
believe, as was a few other small syntax related items.
The E-Book I was following(Much older version of gambas) I don't think
even mentions declaring it as either.
I'm new to sqlite and gambas, I mostly deal with perl and mysql.
Thanks to all who replied to my questions and gave examples.
The community here has always been very helpful.
Post by Olivier Cruilles
Hello,
I think your problem is that you don't understand how to use sqlite database..
You don't renew a connection every time you want to use it.
- You open the database at the beginning of your program
- You work with it by updating it
- Before you close you program, you close the database
--------------------------------------------
PUBLIC $hConn AS Connection <= Error corrected
PUBLIC SUB btnConnect_Click()
$hConn = NEW Connection <= line added
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = $hConn.Create("inventory") <= Error corrected
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Cordialement,
Olivier Cruilles
Post by rocko
Is it DB.Create/DB.Commit?? I was using $hConn.Create and so on.
I'm getting 'Connection Not Opened" error when click the Add_new btn.
PRIVATE $hConn AS Connection
PUBLIC SUB btnConnect_Click()
DIM $hConn AS NEW Connection
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
rTable = DB.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Post by Fabien Bodard
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open
End
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = DB.Create("inventory")
rTable!name = txtName.Text
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF
DB.Commit
end
Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Fabien Bodard
2012-08-09 15:22:36 UTC
Permalink
Normally it can work with private if it is declared in the form that use it
Post by Olivier Cruilles
So to be exact, it's the same mecanism for all other database.
If you declare a variable (as $hConn) in a PUBLIC SUB, the variable is
local of this PUBLIC SUB
so if you want to use a variable in all a Form or Module or Class, you
need to declare your variable at the beginning of this Form and not in a
PUBLIC SUB
When you use a Connection object to open a database, after initialized it
and opened it, the object Connection keep connected to the database, so you
just need to use it.
Cordialement,
Olivier Cruilles
Post by rocko
Thank you sir;
You get a cookie :)
Your example works fine.
'Public' instead of 'Private' for the $hConn as Connection was the key I
believe, as was a few other small syntax related items.
The E-Book I was following(Much older version of gambas) I don't think
even mentions declaring it as either.
I'm new to sqlite and gambas, I mostly deal with perl and mysql.
Thanks to all who replied to my questions and gave examples.
The community here has always been very helpful.
Post by Olivier Cruilles
Hello,
I think your problem is that you don't understand how to use sqlite
database..
Post by rocko
Post by Olivier Cruilles
You don't renew a connection every time you want to use it.
- You open the database at the beginning of your program
- You work with it by updating it
- Before you close you program, you close the database
--------------------------------------------
PUBLIC $hConn AS Connection <= Error corrected
PUBLIC SUB btnConnect_Click()
$hConn = NEW Connection <= line added
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = $hConn.Create("inventory") <= Error corrected
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Cordialement,
Olivier Cruilles
Post by rocko
Is it DB.Create/DB.Commit?? I was using $hConn.Create and so on.
I'm getting 'Connection Not Opened" error when click the Add_new btn.
PRIVATE $hConn AS Connection
PUBLIC SUB btnConnect_Click()
DIM $hConn AS NEW Connection
$hConn.Host = "/home/rocko/DataBases"
$hConn.Name = "my_test.sqlite"
$hConn.Type = "sqlite"
$hConn.Open
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
rTable = DB.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
DB.Commit
PUBLIC SUB btnClose_Click()
$hConn.Close
FMain.Close
Post by Fabien Bodard
Private $hConn as New Connection
Public sub _New()
$hConn .Host = "dir of bdd"
$hConn.Name = "MyBdd"
$hConn.Type = "sqlite"
$hConn.Open
End
PUBLIC SUB btnAdd_Click()
DIM rTable AS Result
rTable = DB.Create("inventory")
rTable!name = txtName.Text
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
return
ENDIF
DB.Commit
end
Public SUb Form_Close
$hConn.CLose
end
Post by rocko
Im now getting error's.
I was getting a "connection not opened" error message, so I add
a $hConn.Open before the $hConn.Begin.
I'm now getting a "Driver name missing" error.
PUBLIC SUB btnAdd_Click()
DIM $hConn AS NEW Connection
DIM rTable AS Result
$hConn.Open
$hConn.Begin
'$hConn.Exec("INSERT INTO inventory VALUES(name), txt.Name")
'$hConn.Commit
rTable = $hConn.Create("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
TRY rTable.Update
IF ERROR THEN
PRINT "Update failed"
Message.Error(ERROR.Text)
ENDIF
ENDIF
$hConn.Commit
$hConn.Close
Post by Fabien Bodard
Post by rocko
Is there anyway to translate that??
google ?
Post by rocko
Post by Fabien Bodard
it's in french but ...
http://www.gambasforge.org/code-56-apprehender-sqlite-avec-gambas.html
------------------------------------------------------------------------------
Post by rocko
Post by Olivier Cruilles
Post by rocko
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
threats.
http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Post by rocko
Post by Olivier Cruilles
Post by rocko
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Post by Olivier Cruilles
Post by rocko
Post by Fabien Bodard
Post by rocko
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Post by Olivier Cruilles
Post by rocko
Post by Fabien Bodard
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by Olivier Cruilles
Post by rocko
Post by Fabien Bodard
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by Olivier Cruilles
Post by rocko
Post by Fabien Bodard
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Post by Olivier Cruilles
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by Olivier Cruilles
Post by rocko
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by Olivier Cruilles
Post by rocko
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Post by Olivier Cruilles
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
Post by rocko
Post by Olivier Cruilles
will include endpoint security, mobile security and the latest in
malware
Post by rocko
Post by Olivier Cruilles
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Post by rocko
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
1970-01-01 00:00:00 UTC
Permalink
Hi,
Try=20
$hConn.Exec("INSERT INTO 'inventory' (your Column) VALUES ('" &
txtName.Text & "')

Ivan

-----Urspr=FCngliche Nachricht-----
Von: rocko [mailto:***@gmail.com]=20
Gesendet: Mittwoch, 8. August 2012 05:14
An: mailing list for gambas users
Betreff: Re: [Gambas-user] Adding values to fields in SQLite table??

So should rTable be set as String not Result??

I've tried both and I still can't get the DB to update.

$hConn.Begin
=20
rTable =3D $hConn.Edit("inventory")
=20
IF rTable.Available THEN=20
rTable!name =3D txtName.Text
rTable.Update
ENDIF=20
=20
$hConn.Commit
FINALLY
$hConn.Close
=20
Post by Adam Ant
8<
=20
Post by rocko
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 =3D ",=20
Error.Text
INC Application.Busy
$hConn.Begin
rTable =3D "Inventory"
<---- 1
Post by Adam Ant
Post by rocko
rTable!name =3D txtName.Text
rTable.Update
<---- 2
Post by Adam Ant
Post by rocko
$hConn.Commit
FINALLY
DEC Application.Busy
$hConn.Close
END
=20
1. You are trying to set a Result to a string value. This wont work.
2. In order for gb.db to execute a database update it must have a=20
writeable result.
=20
=20
rTable=3D$hConn.Edit("Inventory",<some request to get the record you=20
want to update>) IF rTable.Available then
rTable!name=3DtxtName.Text
rTable.Update
END IF
=20
The help on gb.db has plenty of examples for Result and Connection=20
explaining these concepts.
=20
hth
Bruce
=20
----------------------------------------------------------------------
--------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and=20
threat landscape has changed and how IT managers can respond.=20
Discussions will include endpoint security, mobile security and the=20
latest in malware threats.=20
http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------------------------------------------------------------------=
---
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat
landscape has changed and how IT managers can respond. Discussions will
include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
1970-01-01 00:00:00 UTC
Permalink
No no and no
You need to use &1 .... To limit the quoting problems
Post by
Hi,
Try
$hConn.Exec("INSERT INTO 'inventory' (your Column) VALUES ('" &
txtName.Text & "')
Ivan
-----Urspr√ľngliche Nachricht-----
Gesendet: Mittwoch, 8. August 2012 05:14
An: mailing list for gambas users
Betreff: Re: [Gambas-user] Adding values to fields in SQLite table??
So should rTable be set as String not Result??
I've tried both and I still can't get the DB to update.
$hConn.Begin
rTable = $hConn.Edit("inventory")
IF rTable.Available THEN
rTable!name = txtName.Text
rTable.Update
ENDIF
$hConn.Commit
FINALLY
$hConn.Close
Post by Adam Ant
8<
Post by rocko
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"
<---- 1
Post by Adam Ant
Post by rocko
rTable!name = txtName.Text
rTable.Update
<---- 2
Post by Adam Ant
Post by rocko
$hConn.Commit
FINALLY
DEC Application.Busy
$hConn.Close
END
1. You are trying to set a Result to a string value. This wont work.
2. In order for gb.db to execute a database update it must have a
writeable result.
rTable=$hConn.Edit("Inventory",<some request to get the record you
want to update>) IF rTable.Available then
rTable!name=txtName.Text
rTable.Update
END IF
The help on gb.db has plenty of examples for Result and Connection
explaining these concepts.
hth
Bruce
----------------------------------------------------------------------
--------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions will include endpoint security, mobile security and the
latest in malware threats.
http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
----------------------------------------------------------------------------
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat
landscape has changed and how IT managers can respond. Discussions will
include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Continue reading on narkive:
Loading...