[Gambas-user] Need help with database.

Fabien Bodard abidoo.too at ...11...
Sun May 23 18:55:17 CEST 2004


Le dimanche 23 Mai 2004 18:00, Benoit Minisini a écrit :
> On Sunday 23 May 2004 15:16, Fabien Bodard wrote:
> > I'm trying to use the gb method for create a new database insteed the SQL
> > one.
> >
> > But ... i don't understand how to add fields in a table....
> >
> > Fabien
> >
> > This is a part of my test code
> >
> >   DIM Fic AS File
> >   DIM stxt AS String
> >   DIM i AS Integer
> >   DIM j AS Integer
> >
> >   DIM CurTable AS Table
> >   con = NEW Connection
> >   con.Type = "mysql"
> >   con.Host = "localhost"
> >   Con.Login = "root"
> >
> >   con.open
> >   'Vérifie si la base de donnée Vitis existe ... sinon la créé
> >   IF NOT Con.Database.Exist("vitis") THEN con.Database.Create("vitis")
> >   Con.Database.Find("vitis")
> >   IF NOT Con.Tables.Exist("parcellaire") THEN
> >       CurTable = Con.Tables.Create("Parcellaire")
> >
> >   CurTable.Field.Create("idparc", gb.Integer,,0)
> >   CurTable.Field.Create("proprietaire", gb.String, 30," ")
> >   CurTable.Field.Create("fv", gb.String, 3," ")
> >   CurTable.Field.Create("idcommune", gb.Integer, ,0)
> >   'CurTable.Field.Create("idcommune", gb.String, 30," ")
> >   CurTable.Field.Create("lieudit", gb.String, 30," ")
> >   CurTable.Field.Create("section", gb.String, 3," ")
> >   CurTable.Field.Create("cadastre", gb.integer,, 0 )
> >   CurTable.Field.Create("Surface", gb.Float,, 0)
> >   CurTable.Field.Create("nom", gb.string, 30, 0)
> >   CurTable.Field.Create("idCepage", gb.Integer,, 0)
> >   CurTable.Field.Create("Couleur", gb.string, 15, 0)
> >   CurTable.Field.Create("dateplantation", gb.Date,, "1/01/2000")
> >   CurTable.Field.Create("surfaceplante", gb.Float,, 0)
> >   CurTable.Field.Create("idpg", gb.Integer,, 0)
> >   CurTable.Field.Create("entrerang", gb.float,, 0)
> >   CurTable.Field.Create("intercep", gb.float,, 0)
> >   CurTable.Field.Create("abouture", gb.string, 30, 0)
> >
> >   FOR EACH Curtable.Field
> >    PRINT Curtable.Field!name
> >   NEXT
>
> And then... CurTable.Update to create the table.
>
> Regards,

it say me that i need ... to define primarykey but when i do it by

CurTable.Field.Primarykey.Add("idparc")

, it say me ... Not an object !

Fabien




More information about the User mailing list