Page 1 of 1

Cached updates, filter, moving position in datalink, user data input -> access violation in SDAC

Posted: Tue 05 Jul 2005 13:49
by Ludek
Hi,
I'm having trouble with the newest version of SDAC. I need some special drawing in TDBGrid - I've written an TDBGrid descendant and overriden the Paint method to scan all the rows visible in grid:

procedure TMyDBGrid.Paint;
var
i, oldactiverec: integer;
begin
oldactiverec := Datalink.ActiveRecord;
try
for i := 0 to Datalink.BufferCount - 1 do begin
Datalink.ActiveRecord := i;
if datasource.dataset.fields[0].AsVariant = '1' then begin
// some processing
end;
end;
finally
Datalink.ActiveRecord := oldactiverec;
end;
inherited;
end;

It worked fine using BDE and it works also fine using SDAC, but an access vilotation (sometimes only an assert) occurs somewhere in SDAC units under following circumstances:
1. the TMSQuery shown in the grid has active cached updates
2. the TMSQuery is filtered and some rows are because of this filter not visible
3. user begins to the change data in the grid - immediately after keypress this AV occurs

Do you have an idea? I could send you the example.

Thanks.

Posted: Tue 05 Jul 2005 14:39
by Ludek.
Hmm, it's more complicated than I wrote. I has also something to do with row count in the query and perhaps also something more... I'm sending you the delphi source and the db creation script.

Posted: Wed 06 Jul 2005 09:09
by Ikar
We examined your example and couldn't reproduce the problem. Try to disable ExceptionLog from file of the project.

Do you use SDAC Trial version?

Posted: Wed 06 Jul 2005 10:01
by Guest
I'm using full version 3.55.0.16 and delphi 7 now.
I removed the ExceptionLog - without any change, still access violation.
I tried it on 2 workstations (windows server 2003 and windows 2000) - exception on both of them.
I simply start the exe, jump to the column "summe" a press there "1" - immediate exception.
Should I send you also the compiled executable and the test-database?

Posted: Wed 06 Jul 2005 10:10
by Ludek
this is the generated database creation script (the datarows are same as in the sent example) - perhaps some problem with collation order (?)

CREATE DATABASE [test] ON (NAME = N'test', FILENAME = N'C:\Programme\Microsoft SQL Server\MSSQL\data\test.mdf' , SIZE = 1, FILEGROWTH = 10%) LOG ON (NAME = N'test_log', FILENAME = N'C:\Programme\Microsoft SQL Server\MSSQL\data\test_log.LDF' , FILEGROWTH = 10%)
COLLATE Latin1_General_CI_AS
GO

exec sp_dboption N'test', N'autoclose', N'false'
GO

exec sp_dboption N'test', N'bulkcopy', N'false'
GO

exec sp_dboption N'test', N'trunc. log', N'false'
GO

exec sp_dboption N'test', N'torn page detection', N'true'
GO

exec sp_dboption N'test', N'read only', N'false'
GO

exec sp_dboption N'test', N'dbo use', N'false'
GO

exec sp_dboption N'test', N'single', N'false'
GO

exec sp_dboption N'test', N'autoshrink', N'false'
GO

exec sp_dboption N'test', N'ANSI null default', N'false'
GO

exec sp_dboption N'test', N'recursive triggers', N'false'
GO

exec sp_dboption N'test', N'ANSI nulls', N'false'
GO

exec sp_dboption N'test', N'concat null yields null', N'false'
GO

exec sp_dboption N'test', N'cursor close on commit', N'false'
GO

exec sp_dboption N'test', N'default to local cursor', N'false'
GO

exec sp_dboption N'test', N'quoted identifier', N'false'
GO

exec sp_dboption N'test', N'ANSI warnings', N'false'
GO

exec sp_dboption N'test', N'auto create statistics', N'true'
GO

exec sp_dboption N'test', N'auto update statistics', N'true'
GO

if( ( (@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 724) ) or ( (@@microsoftversion / power(2, 24) = 7) and (@@microsoftversion & 0xffff >= 1082) ) )
exec sp_dboption N'test', N'db chaining', N'false'
GO

use [test]
GO

CREATE TABLE [dbo].[handytarife] (
[name] [char] (40) COLLATE Latin1_General_CI_AS NULL
) ON [PRIMARY]
GO

Posted: Wed 06 Jul 2005 14:09
by Ikar
> Should I send you also the compiled executable and the test-database?

Try at first to download the last version SDAC 3.55.0.16

Posted: Wed 06 Jul 2005 14:09
by Ikar
> Should I send you also the compiled executable and the test-database?

Try at first to download the last version SDAC 3.55.0.16

Posted: Wed 06 Jul 2005 14:19
by Ludek
Hi Ikar,
as you can read in my previous message, I've already done this; nothing changed.

Posted: Fri 08 Jul 2005 08:33
by Ludek
Hi folks,
how about my problem? Do I have to deliver some more data or has the problem been already reproduced?

Posted: Fri 08 Jul 2005 14:02
by Ikar
Yesterday we sent you email and asked to change your sample so it would be possible to change server name, user name, password and database name.

Posted: Fri 08 Jul 2005 14:50
by Ludek
Ooops. I didn't think about it. I'll do it today! Sorry, my fault.

Posted: Mon 11 Jul 2005 10:51
by Ikar
Thank you for example, we reproduce the problem.

The reason of the problem is that in the loop of drawing ActiveRecords greater then must fit for specified filter are chosen. Standard DBGrid as a loop parameter uses DataLink.DataSource.DataSet.FRecordCount (see TCustomDBGrid.UpdateRowCount).
At your case it would be correct to use the same algorithm.

Posted: Mon 11 Jul 2005 12:00
by Ludek
THX!!! The Datalink.RecordCount seems to be really the correct boundary. I'm only wondering, that the access violation didn't appear immediately, first when the user started to edit... :shock: OK!!!