Jump to content

UniDBGrid/DataSet refresh


misc

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 comment
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 comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...