SQL Server 6.5 vs DELPHI (DBGrid) 
Author Message
 SQL Server 6.5 vs DELPHI (DBGrid)

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.



Wed, 18 Jun 1902 08:00:00 GMT  
 SQL Server 6.5 vs DELPHI (DBGrid)


Quote:
> 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

This error message (Table does not ... uniquely indexed) appears if you
call Refresh method for a TQuery. I have a small project with a TTable
and a TQuery and this method for a button:

procedure TForm2.Button1Click(Sender: TObject);
begin
  //Query1.Refresh;
  Table1.Refresh;
end;
If I uncomment first line, I get this error message, else is everything
o.k.

Regards,Palo

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Wed, 18 Jun 1902 08:00:00 GMT  
 SQL Server 6.5 vs DELPHI (DBGrid)
Hi Bernardo,

I am not very knowledgeable with Delphi database programming, but maybe
a few hints:

When you post a record in the DBGrid, Delphi will insert the record
where it should go in using the supplied index. That means that if you
are inserting a record in the beginning of the table, the new inserted
record SHOULD/MIGHT be inserted at the end. If you have a filter
specified, that could explain why you do not see the new record.

A primary constraint does not mean a UNIQUE index. Check your table if
it has a unique index, and if so, set the DefaultIndex property to True
or specify the index name.

regards
Stephan Marais


Quote:

> 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.



Wed, 18 Jun 1902 08:00:00 GMT  
 SQL Server 6.5 vs DELPHI (DBGrid)


Quote:
> 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.

Set CachedUpdates to True. You have to call ApplyUpdates method
(perhaps in AfterPost method).

This is perhaps common to all remote database servers (I tested it also
with InterBase).

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. MS-SQL server 6.5 vs Interbase server ???

2. SQL Server 6.5: Native driver vs. ODBC

3. Delphi 1.0 to SQL Server 6.5 - connections!

4. Delphi 2.0 & SQL SERVER 6.5

5. Server Cursors SQL Server 6.5

6. Delphi and Sql/Server 6.5

7. Delphi 1 Desktop/MS SQL Server 6/6.5

8. Accessing SQL Server 6.5 from Delphi 3.0 Cli/svr

9. MS SQL Server 6.5 + Delphi 3.0 = ???

10. Delphi, 16bit Native SQL-Server 6.5 native/ ODBC drivers

11. Blobs greater than 32K in SQL-Server 6.5/Delphi 3.0

12. Delphi 3.0 and MS SQL Server 6.5

 

 
Powered by phpBB® Forum Software