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

Adam Ant adamnt42 at ...626...
Wed Aug 8 04:48:13 CEST 2012


On Wed, Aug 8, 2012 at 4:48 AM, rocko <sunblaster5 at ...626...> wrote:
8<

> 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




More information about the User mailing list