[Gambas-user] Adding values to fields in SQLite table??

rocko sunblaster5 at ...626...
Wed Aug 8 00:09:55 CEST 2012


Ok I tried this:
  $hConn.Begin
  $hConn.Exec("INSERT INTO inventory VALUES(name)", txtName.Text)
  $hConn.Commit

Without success.

On Tue, 2012-08-07 at 23:09 +0200, M. Cs. wrote:
> 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
> 
> 2012/8/7 rocko <sunblaster5 at ...626...>
> 
> > 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.
> >
> >
> >
> >
> >
> >
> > ------------------------------------------------------------------------------
> > 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
> > Gambas-user at lists.sourceforge.net
> > 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
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user






More information about the User mailing list