Jump to content

UniDBGrid/DataSet refresh


Recommended Posts

Hello,

 

i have a problem with a UniDBGrid with the following situation:

 

Every time i make a SQL Call with "insert into" on my FireBird DB for the first time for a new user (of my cms, DB is not empty) and refresh the grid, the columns of my table are there but the entry is not. When i delete the entry (dbgrid is then empty) and make another call (insert into) and the same refresh method, the grid refreshes and i see the entry in the database. 

 

My Question is, is this the right way?:

 

1. SQL call: insert into...

2. Database.ExecuteDirect(..)...

3. DBGrid.DataSource.DataSet.Open;

4. DBGrid.DataSource.DataSet.Refresh;

5. DBGrid.Refresh;

 

Do you have any other suggestions or ideas why it doesnt work on the first call?

Link to post
Share on other sites

You have to do a Commit or better a  CommitRetaining after the insert .

After that do Close and Open for then Query that displays data.

Refresh does not always work. In different DB engines there are different

behaviors of the Refresh. TIBQuery, TUniQuery refreshes only the current reccord.

That is it gets the id for the record and refetches the data. As you are after an insert, the

client does not know the id of the new record and gets nothing. 

The Commit/Close/Open/Last sequence refetches all the records and goes to the last one

which happens to be your insert.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...