[Gambas-user] Managing databases

Charlie Reinl Karl.Reinl at ...9...
Tue Dec 26 19:42:59 CET 2006


Am Dienstag, den 26.12.2006, 15:35 +0100 schrieb Leonardo Miliani:
> I've tried to look at the example projects but I didn't understand how
> the DB connections work with Gambas... sorry :-(
> 
> I'm creating a project to manage an SQLite3 database in which I'll put
> some tables to archive an agenda and other infos.
> 
> I would like to know how to select the value of a field in a table....
> Let's suppose that my DB will contain these tables and fields:
> 
> CODES
> typeA
> typeB
> 
> AGENDA
> code
> address
> phone
> 
> I will store 2 name types, typeA and typeB, which will have different
> codes. If I will be able to create a new contact I will first look for
> the avaible free code (Codes.typeA or Codes.typeB) and then I will
> create the contact using in Agenda.code the above code.
> 
> I've connected to my SQLite3 DB named archive with this code:
> 
> PUBLIC SUB New_contact()
> DIM hConnection AS NEW Connection
> DIM hTable AS result
> DIM TypeA, TypeB AS Integer
> 
>   hConnection.Name = Application.Path & "/archive"
>   hConnection.Type = "sqlite3"
>   hConnection.OPEN
> 
> END
> 
> But now I don't know how to select the value stored in table CODES and
> field TypeA, and how to create a new field in table AGENDA.
> 
> Any suggestion will be welcome :-)
> 
Salut Leonardo,

send you an example, a short project, where you can write, look and
delete records in your AGENDA table.

I didn't understand whats the job of table CODES, so I made a Function
GetNewID for getting a new counter for code in AGENDA .

Keep attention this Function sets his counte + 1 while getting the cout
of existing records, that can be wrong, if you delete one.

Hope that example helps.

Amicalment
Charlie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestDB-0.0.1.tar.gz
Type: application/x-compressed-tar
Size: 5358 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20061226/d28c5442/attachment.bin>


More information about the User mailing list