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:
Qt Code:
  1. Query = "CREATE TABLE `persons` ("
  2. "`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,"
  3. "`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:

Qt Code:
  1. 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