Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to use SQLite iwith c#, the autoincreement attribute for a field in primary key seems not working properly :-\

 

the code is

 

//Globals

SQLiteClient db;

 

//.....creating table

db.Execute("CREATE TABLE tblProva (id INT AUTOINCREMENT ,name VARCHAR( 255 ) NOT NULL ,PRIMARY KEY ( id ) ) ");

 

//.....inserting row

db.Execute("INSERT INTO tblProva (nome) VALUES ('ciao')");

 

//..then the select

SQLiteResultSet results;

results = db.Execute("SELECT * FROM tblProva ");

foreach (ArrayList arr in results.Rows)

{

foreach(object j in arr)

Console.Write("\t" + Convert.ToString(j) );

Console.WriteLine();

}

 

//but it doesn't insert an autoincrement INT into id field!! :confused: , there's undefined value instead... can u help me?

Posted

If you would have taken a look in the SQLite manual you would have seen,

that an autoincrement column is created with

 

db.Execute("CREATE TABLE tblProva (id INTEGER PRIMARY KEY,name VARCHAR( 255 ) NOT NULL) ");

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...