[Gambas-user] Primary Key missing?

Benoît Minisini gambas at ...1...
Fri Nov 26 00:03:59 CET 2010


> hello,
> 
> prooving my sqlite code, i have several buttons on a form, whose subs
> should do the same work in different ways (one just using Exec() method,
> the other does all work with the gambas objects (editing fields etc.)).
> 
> after this code:
> 
> Button2_Click:
> 
>    DIM hResult AS Result
> 
>    hConnection.Exec("create table test(id integer primary key, name
> varchar(10));")
>    hConnection.Exec("insert into test(name) values(\"Aaron\");")
>    hConnection.Exec("insert into test(name) values('Zacharias');")
> 
>    '1|Aaron
>    '2|Zacharias
> 
> i have another button which should edit this table:
> 
>    DIM hResult AS Result
> 
>    hResult = hConnection.Edit("test", "name=&1", "Aaron")
>    hResult["name"] = "Adam"
>    hResult.Update()
> 
> 
> but in the line where the Edit()-function is used, i get the error that
> there is no primary key in my table but didn't i specify one creating
> the table?
> 
> by the way... i found that i wasn't able to even find a command to edit
> a record in terminal; i wanted to proof if the sqlite3 program with the
> same commands would tell me the same...
> 
> regards,
> tobi
> 

The syntax I know for sqlite is:

create table test(id integer, name varchar(10), primary key(id))

Try to create table by using the Table class, and not the Exec() method.

Otherwise, send me your sqlite database so that I look at it.

Regards,

-- 
Benoît Minisini




More information about the User mailing list