> Hi all,
> Some months ago I've written some posts about problems with SQL Server
> and DBGrid in Delphi 3. They can be summarized as follows:
> 1) Records are disappearing from the dataset after they are inserted and
> posted in the DBGrid. The only remedy to this is to reopen the query
> assigned to the datasource for the DBGrid in question.
> 2) If we use a TTable, we couldn't use the Refresh method. Doing so will
> raise an exception with a message like "Table does not support this
> operation because it is not uniquely indexed.". But the table IS
> uniquely indexed (it has a primary key constraint, and I've also tried
> using an Identity Column...). It seems that the BDE is unable to
> retrieve this information from the SQL Server database. I've used SQL
> Links and an ODBC data source, both (doesn't) work the same in regards
> to this.
> I'm writting this because I was wondering if anyone knows how to
> overcome these problems. There are many queries which takes a few
> seconds to open and I do not want to close and open them every time a
> new record is included in the dataset using the DBGrid.
> You can experience the problems outlined above simply by creating a
> simple table in the SQL Server, let's say with two fields: ID = int
> (PRIMARY_KEY), Name = VARCHAR(50). You may name it 'test_table' if you
> want. After that, execute the database explorer, open the database where
> you've created the 'test_table', log on and go to the Enter SQL tab and
> type 'SELECT * FROM test_table', hit the execute query button or press
> CTRL+E. You will see an empty grid, enter a new row on it (remember to
> have the option 'Request Live Query' set to true!). Try entering more
> rows and see how strange will be the behavior of the DBGrid (records
> will disappear, will change position, etc.). Reopen the query (hit
> CTRL+E) and all the rows will be there, no record will be lost (at least
> that is true).
> If you want to see the second problem by yourself, just select the table
> in the Tables panel and click on the Data tab, after that hit the
> refresh button and the exception will be raised.
> If anyone has hints or knows the solution for those problems please,
> post them here for everybodys happiness :-).
> I apologize for writting that much, and for commiting so many offenses
> to the english language (remember, I am not a native english speaker).
> Best regards to you all,
> Felipe Rocha Machado
> GPS Tecnologia Ltda.