I insert multiple data into a sqlite table and get always the same ID back. But the field Id is configured as PK + autoinc Id.
I use this as connection string:
public static void SetConnectionString(string dataDataAccessPath)
{
_connectionString = String.Format(@"Data Source={0};Foreign K开发者_JAVA技巧eys=ON", dataDataAccessPath);
}
This "Foreign Keys=ON" was implemented for the connection besides the "PRAGMA foreign_keys = ON;" which had to be executed for every opened connection.
Now I wonder why the new attribute on the connectionstring does not work...
Do I something wrong?
I'm not an expert on SQLite (in fact I have no practical experience with it) but I would imagine that whether or not your IDENTITY
fields automatically increment with your insert has something to do more with the definition of the table than with the connection string you are using.
Be reminded that you cannot increment a FOREIGN KEY
per se, but rather you need to increment the table with the IDENTITY
field that serves as the PRIMARY KEY
that the FOREIGN KEY
then references.
Can you add the definition of the table that you are having trouble with?
精彩评论