[Gambas-user] create tables

Werner werda at ...1000...
Tue Jun 21 19:23:37 CEST 2005


PaquitoSoft wrote:

>Hi all!
>
>I'm using Gambas 1.9.8 under Debian/GNU Linux
>
>I want my application to create a database the first time it is run.
>So I check if it already exists and I create it if not.
>Until here everything is ok, but the problem arraives when i try to
>create the tables for the database.
>This is how I'm trying:
>
>DIM conexion as Connection
>DIM tabla as Table
>DIM location as String
>
>WITH conexion
>    .Type = "sqlite"
>    .Host = location
>    .Open()
>	
>    IF .Databases.Exist("Paquito") THEN
>      PRINT "Database already exists"
>    ELSE
>      .Databases.Add("Paquito")
>      PRINT "New Database created"
>    END IF
>
>    .Close()
>    .Host = location &/ "Paquito"
>    .Open()
>
>    tabla = .Tables.Add("preferencias")
>    tabla.Fields.Add("idioma", GB.String, 5)
>    tabla.Fields.Add("interfaz", GB.String, 5)
>    tabla.Fields.Add("maxUp", GB.Integer)
>    tabla.Fields.Add("maxDown", GB.Integer)
>    tabla.Update()
>    .Close()
>END WITH
>
>location is a String containing the directory where I will store the
>database.
>After I run this code I get a new Database in that folder with the name
>I put and, of course, is a sqlite sigle-fil database.
>The problem is that no table is created within the database, so...
>What am I doing wrong??
>
>Thank you all guys! this mailing list is great
>
>  
>
You migth want to try

DIM conexion as NEW Connection 'to create an instance

Werner





More information about the User mailing list