Hi,
I have tried to work with SQlite I have created a connection, a database and a table. Everything seems ready but when I tried to add some records using QSqlDatabase::exec() I faild because I need to provide the primary key for each column I have to add.
If this is my table:
Query = "CREATE TABLE `persons` ("
"`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,"
"`name` VARCHAR( 255 ) NOT NULL)";
Query = "CREATE TABLE `persons` ("
"`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,"
"`name` VARCHAR( 255 ) NOT NULL)";
To copy to clipboard, switch view to plain text mode
And this is my Query for records to be added from a LineEdit object:
QString submitQuery
= "INSERT INTO `persons` (`id`, `name`) VALUES (NULL, '" + personName
+ "')";
QString submitQuery = "INSERT INTO `persons` (`id`, `name`) VALUES (NULL, '" + personName + "')";
To copy to clipboard, switch view to plain text mode
Is there any way to make the `id field filled automatically just like with PHP. It should be increased by one every time I added a record.
Thank you,
Mohammad AlHobayyeb
Bookmarks