Have another trouble with the SQLite.
I use autoincrement primary key fields and after adding new record with 'Append'/'Post' methods of TUniQuery the value of Primary key field is '0'. So i need to refresh dataset to aquire actual value.
SQLite primart key value after post
Hello,
I can not reproduce the problem.
Please try to create the following table:
CREATE TABLE test
(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
text VARCHAR(50)
)
and insert data into it like this:
UniQuery1.SQL.Clear;
UniQuery1.SQL.Text := 'SELECT * FROM test';
UniQuery1.Open;
UniQuery1.Append;
UniQuery1.FieldByName('text').AsString:= 'test';
UniQuery1.Post;
ShowMessage(UniQuery1.FieldByName('id').AsString);
you should see correct data from the ID field.
I have tested it on the 3.50.0.13 version of UniDAC.
I can not reproduce the problem.
Please try to create the following table:
CREATE TABLE test
(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
text VARCHAR(50)
)
and insert data into it like this:
UniQuery1.SQL.Clear;
UniQuery1.SQL.Text := 'SELECT * FROM test';
UniQuery1.Open;
UniQuery1.Append;
UniQuery1.FieldByName('text').AsString:= 'test';
UniQuery1.Post;
ShowMessage(UniQuery1.FieldByName('id').AsString);
you should see correct data from the ID field.
I have tested it on the 3.50.0.13 version of UniDAC.
I've compared your example (it works) with my. I use these syntax:
It seems that quotes make difference. With field name in quotes id is not returned after 'Post' and without them it works well.
I think it should works with quotes too.
Code: Select all
CREATE TABLE "ProductType" (
"ProductType_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"ProductType_name" VARCHAR(100)
)I think it should works with quotes too.