Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How to add a record to a single column table using FireDAC


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Jan 6, 2015 7:50 AM Last Post By: tim crouse
tim crouse

Posts: 83
Registered: 2/11/02
How to add a record to a single column table using FireDAC  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 5, 2015 11:26 AM
The following code generates an SQLite Locked error

The button event is to use a string from and edit control and add it to teh end of teh DB Table.


procedure TForm1.Button1Click(Sender: TObject);
Var
NEW_RECORD : String;

begin

FDQuery1.SQL.Text := 'select * From Table_1';
FDQuery1.Open;
NEW_RECORD := Edit1.Text;
FDQuery1.Append;
FDQuery1.FieldByName('Field1').AsString := NEW_RECORD;
FDQuery1.Post;

end;

Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: How to add a record to a single column table using FireDAC  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 6, 2015 12:06 AM   in response to: tim crouse in response to: tim crouse
Set connection parameter LockingMode to Normal.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
tim crouse

Posts: 83
Registered: 2/11/02
Re: How to add a record to a single column table using FireDAC  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 6, 2015 4:30 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
Set connection parameter LockingMode to Normal.

--
With best regards,
Dmitry Arefiev / FireDAC Architect

I verified the connection update options are all enabled and that lockmode is set to none, I also added the settings to the procedure as follows:

FDConnection1.UpdateOptions.ReadOnly := False;
FDConnection1.UpdateOptions.EnableInsert := True;
FDConnection1.UpdateOptions.LockMode := lmnone;

The update code follows on here......

At the moment hte SQLite DB will accept (1) append or (1) insert, immediatly after it accepts the new item and it is display in the link dbgrid the locked error pops up.
The DB will keep accepting changes but only as an overwrite of the first appended or inserted item..

I verified the file is not write protected and i have also recreated anew test db, but each time I get teh same behavior.
Thanks
-Tim C.


UPDATE to Reply

I changed the Query Cachedupdate property to TRUE
and changed the FDQuery1.Post statement to:
FDQuery1.ApplyUpdate()

The lock error does not appear but the DB only accepts (1) update and overwrites the previous update.
The data is not actually getting posted to teh db though, I closed the app and restarted it to get a reload of the data into the grid but only the original set of data appears in the grid.

Edited by: tim crouse on Jan 6, 2015 6:51 AM

tim crouse

Posts: 83
Registered: 2/11/02
Re: How to add a record to a single column table using FireDAC  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 6, 2015 7:01 AM   in response to: tim crouse in response to: tim crouse
tim crouse wrote:
Dmitry Arefiev wrote:
Set connection parameter LockingMode to Normal.

--
With best regards,
Dmitry Arefiev / FireDAC Architect

I verified the connection update options are all enabled and that lockmode is set to none, I also added the settings to the procedure as follows:

FDConnection1.UpdateOptions.ReadOnly := False;
FDConnection1.UpdateOptions.EnableInsert := True;
FDConnection1.UpdateOptions.LockMode := lmnone;

The update code follows on here......

At the moment hte SQLite DB will accept (1) append or (1) insert, immediatly after it accepts the new item and it is display in the link dbgrid the locked error pops up.
The DB will keep accepting changes but only as an overwrite of the first appended or inserted item..

I verified the file is not write protected and i have also recreated anew test db, but each time I get teh same behavior.
Thanks
-Tim C.


UPDATE to Reply

I changed the Query Cachedupdate property to TRUE
and changed the FDQuery1.Post statement to:
FDQuery1.ApplyUpdate()

The lock error does not appear but the DB only accepts (1) update and overwrites the previous update.
The data is not actually getting posted to teh db though, I closed the app and restarted it to get a reload of the data into the grid but only the original set of data appears in the grid.

Edited by: tim crouse on Jan 6, 2015 6:51 AM


UPDATE

I changed the FDQuery1 cachedupdate property to TRUE
I changed the FDQuery1.Post to:
FDQuery1.ApplyUpdate()

The DB appears to accept (1) update any other updates simply overwrite the original update
No Lock notice appears
I restart teh app to see if the data is actually going into the DB (via a grid reload) but only the orignial data appears in the grid.

tim crouse

Posts: 83
Registered: 2/11/02
Re: How to add a record to a single column table using FireDAC  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 6, 2015 7:50 AM   in response to: tim crouse in response to: tim crouse
tim crouse wrote:
tim crouse wrote:
Dmitry Arefiev wrote:
Set connection parameter LockingMode to Normal.

--
With best regards,
Dmitry Arefiev / FireDAC Architect

I verified the connection update options are all enabled and that lockmode is set to none, I also added the settings to the procedure as follows:

FDConnection1.UpdateOptions.ReadOnly := False;
FDConnection1.UpdateOptions.EnableInsert := True;
FDConnection1.UpdateOptions.LockMode := lmnone;

The update code follows on here......

At the moment hte SQLite DB will accept (1) append or (1) insert, immediatly after it accepts the new item and it is display in the link dbgrid the locked error pops up.
The DB will keep accepting changes but only as an overwrite of the first appended or inserted item..

I verified the file is not write protected and i have also recreated anew test db, but each time I get teh same behavior.
Thanks
-Tim C.


UPDATE to Reply

I changed the Query Cachedupdate property to TRUE
and changed the FDQuery1.Post statement to:
FDQuery1.ApplyUpdate()

The lock error does not appear but the DB only accepts (1) update and overwrites the previous update.
The data is not actually getting posted to teh db though, I closed the app and restarted it to get a reload of the data into the grid but only the original set of data appears in the grid.

Edited by: tim crouse on Jan 6, 2015 6:51 AM


UPDATE

I changed the FDQuery1 cachedupdate property to TRUE
I changed the FDQuery1.Post to:
FDQuery1.ApplyUpdate()

The DB appears to accept (1) update any other updates simply overwrite the original update
No Lock notice appears
I restart teh app to see if the data is actually going into the DB (via a grid reload) but only the orignial data appears in the grid.


FINAL UPDATE

When Dimitry referred me to locking mode to be set to normal I went to FDConnection >> Options Locking Paramter Group and set it to lmNone

Where I had to go was to the FDConnection Definition Tab >> LockingMode Parameter, Change that freom Exclusive to Normal.

Not sure why a new connection shows up like this but I have yet to see any tutorial or video mention it.

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02