R Ramirez Member Licensed User Longtime User Jul 31, 2011 #1 Hello, it's again me I want to make an index (primary key) in a SQL table and want to use the AUTO_INCREMENT parametre Code: Copy 'Table creation query="CREATE TABLE IF NOT EXISTS [table] ([Index] INTEGER AUTO_INCREMENT PRIMARY KEY, [Data1] TEXT, [Data2] TEXT)" SQL1.ExecNonQuery(query) To Add a data, I try this code: Code: Copy ' Add data query="INSERT INTO table VALUES ('text1', 'text2')" SQL1.ExecNonQuery(query) I receive a message "Table has 3 column but only 2 values were supplied" So I change my program to : To Add a data, I try this code: Code: Copy ' Add data query="INSERT INTO table VALUES ('','text1', 'text2')" SQL1.ExecNonQuery(query) But now, when I check the table (SQLViewer), the column 'index' is empty. Where is my mistake ? A+
Hello, it's again me I want to make an index (primary key) in a SQL table and want to use the AUTO_INCREMENT parametre Code: Copy 'Table creation query="CREATE TABLE IF NOT EXISTS [table] ([Index] INTEGER AUTO_INCREMENT PRIMARY KEY, [Data1] TEXT, [Data2] TEXT)" SQL1.ExecNonQuery(query) To Add a data, I try this code: Code: Copy ' Add data query="INSERT INTO table VALUES ('text1', 'text2')" SQL1.ExecNonQuery(query) I receive a message "Table has 3 column but only 2 values were supplied" So I change my program to : To Add a data, I try this code: Code: Copy ' Add data query="INSERT INTO table VALUES ('','text1', 'text2')" SQL1.ExecNonQuery(query) But now, when I check the table (SQLViewer), the column 'index' is empty. Where is my mistake ? A+
Kiffi Well-Known Member Licensed User Longtime User Jul 31, 2011 #2 try this one: Code: Copy ' Add data query="INSERT INTO table ([Data1], [Data2]) VALUES ('text1', 'text2')" SQL1.ExecNonQuery(query) Greetings ... Kiffi EDIT: BTW: It's no good idea to name a Table 'table' because it is a reserved word. Last edited: Jul 31, 2011 Upvote 0
try this one: Code: Copy ' Add data query="INSERT INTO table ([Data1], [Data2]) VALUES ('text1', 'text2')" SQL1.ExecNonQuery(query) Greetings ... Kiffi EDIT: BTW: It's no good idea to name a Table 'table' because it is a reserved word.
klaus Expert Licensed User Longtime User Jul 31, 2011 #3 I use following code: Code: Copy query="INSERT INTO table VALUES (NULL, 'text1', 'text2')" SQL1.ExecNonQuery(query) The first column is declared as INTEGER PRIMARY KEY. Best regards. Upvote 0
I use following code: Code: Copy query="INSERT INTO table VALUES (NULL, 'text1', 'text2')" SQL1.ExecNonQuery(query) The first column is declared as INTEGER PRIMARY KEY. Best regards.
R Ramirez Member Licensed User Longtime User Jul 31, 2011 #4 OK thx all ! It works ! I delete the AUTO_INCREMENT from the creation of the table because an error message appears, and that work too. Kiffi: don't worry I don't use the name 'table' for my table in my program, I just use this name to be more explicite. Thanx again Upvote 0
OK thx all ! It works ! I delete the AUTO_INCREMENT from the creation of the table because an error message appears, and that work too. Kiffi: don't worry I don't use the name 'table' for my table in my program, I just use this name to be more explicite. Thanx again
ciginfo Well-Known Member Licensed User Longtime User Jul 30, 2012 #5 And is this right? SQL1.ExecNonQuery2("INSERT INTO table1 VALUES(?, ?, ?)", Array As Object(Null, Text1, Text2)) Click to expand... Thank you Upvote 0
And is this right? SQL1.ExecNonQuery2("INSERT INTO table1 VALUES(?, ?, ?)", Array As Object(Null, Text1, Text2)) Click to expand... Thank you