Board index » delphi » Repositioning a field corrupts DBGrid !!!

Repositioning a field corrupts DBGrid !!!


2003-10-24 01:02:33 PM
delphi42
With a simple one record dbgrid with only 10 fields (f1..f10), moving
field f10 to the position between f08 and f09 by dragging from the
column header changes the display values of fields f09 and f10:
Originally: f09=<empty>, f10=?0?
After repositioning field f10: f09=12/30/99, F10=<empty>
Is this a known “feature?of dbgrid, tadostoredproc or ADO?
I have seen this kind of behaviour with several grids with more than 9
columns.
Is there a workaround?
Technical details of my test environment:
My test application is one form application with no handwritten code.
The form has only components TAdoStoredProc, TDatasource and TDBGrid.
I got the same results with Delphi Enterprise 5 and 6.
I have tried my test applications with Windows XP (ADO 2.7) and WinNT (ADO
2.5) with same results.
I have used SQL Server 7 with the following test table:
CREATE TABLE [dbo].[gridtest] (
[f01] [varchar] (10) NOT NULL ,
[f02] [varchar] (10) NULL ,
[f03] [varchar] (10) NULL ,
[f04] [varchar] (10) NULL ,
[f05] [varchar] (10) NULL ,
[f06] [varchar] (10) NULL ,
[f07] [varchar] (10) NULL ,
[f08] [varchar] (10) NULL ,
[f09] [datetime] NULL ,
[f10] [varchar] (10) NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[gridtest] WITH NOCHECK ADD
CONSTRAINT [PK_gridtest] PRIMARY KEY NONCLUSTERED
(
[f01]
) ON [PRIMARY]
GO
insert
gridtest
(f01, f02, f03, f04, f05, f06, f07, f08, f09, f10)
values
('01', '02', '03', '04', '05', '06', '07', '08', NULL, '10')
GO
The following script creates the stored procedure that I have used in my
tests:
SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON
GO
CREATE PROCEDURE [Test]
AS
select * from gridtest
GO
SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON
GO
I sincerely hope that someone could solve this annoying problem!
--Ville
 
 

Re:Repositioning a field corrupts DBGrid !!!

The connection string I have used in my test application as
AdoStoredProc1.ConnectionString is
Provider=SQLOLEDB.1;Password=test;Persist Security Info=True;User
ID=test;Initial Catalog=GridTest;Data Source=P3
--Ville
 

Re:Repositioning a field corrupts DBGrid !!!

"Ville" <XXXX@XXXXX.COM>schrieb im Newsbeitrag
Quote
With a simple one record dbgrid with only 10 fields (f1..f10), moving
field f10 to the position between f08 and f09 by dragging from the
column header changes the display values of fields f09 and f10:
Originally: f09=<empty>, f10=?0?
After repositioning field f10: f09=12/30/99, F10=<empty>
Is this a known “feature?of dbgrid, tadostoredproc or ADO?
I have seen this kind of behaviour with several grids with more than 9
columns.
Is there a workaround?

Technical details of my test environment:
My test application is one form application with no handwritten code.
The form has only components TAdoStoredProc, TDatasource and TDBGrid.
I got the same results with Delphi Enterprise 5 and 6.
I have tried my test applications with Windows XP (ADO 2.7) and WinNT (ADO
2.5) with same results.
I have used SQL Server 7 with the following test table:

CREATE TABLE [dbo].[gridtest] (
[f01] [varchar] (10) NOT NULL ,
[f02] [varchar] (10) NULL ,
[f03] [varchar] (10) NULL ,
[f04] [varchar] (10) NULL ,
[f05] [varchar] (10) NULL ,
[f06] [varchar] (10) NULL ,
[f07] [varchar] (10) NULL ,
[f08] [varchar] (10) NULL ,
[f09] [datetime] NULL ,
[f10] [varchar] (10) NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[gridtest] WITH NOCHECK ADD
CONSTRAINT [PK_gridtest] PRIMARY KEY NONCLUSTERED
(
[f01]
) ON [PRIMARY]
GO

insert
gridtest
(f01, f02, f03, f04, f05, f06, f07, f08, f09, f10)
values
('01', '02', '03', '04', '05', '06', '07', '08', NULL, '10')
GO

The following script creates the stored procedure that I have used in my
tests:

SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON
GO

CREATE PROCEDURE [Test]
AS
select * from gridtest

GO
SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON
GO

I sincerely hope that someone could solve this annoying problem!
Hi,
i have reproduced your bug using this enviroment:
- SQL Server 2000 SP3 running on Windows 2000 Srv.
- Delphi 5.02 Prof. (ADO Update 2)
- MDAC V2.8
It seems that the values of the properties
.FieldByName('f09').IsNull and
.FieldByName('f10').IsNull
are swapped!
Your test using a TADOQuery (instead of TAdoStoredProc) works
without any problems.
I suppose it is not a bug in TDBGrid, but in the Unit ADODB.pas.
Andreas
Database Explorer for ADO (Freeware)
mitglied.lycos.de/ajs/adodeskexe.zip
 

Re:Repositioning a field corrupts DBGrid !!!

Andreas Schmidt writes:
Quote
Your test using a TADOQuery (instead of TAdoStoredProc) works
without any problems.
Thanks Andreas,
I might use your solution. The value in AdoQuery.SQL can be
"exec spname :par1 :par2..."
So I could use my stored procedures like before.
I'm still little reluctant, because both TAdoQuery and TAdoStoredProc
are decendants of TAdoCustomDataSet. I surely hope that the bug is not
in TAdoCustomDataSet.
The bug surfaces itself quite randomly. In my example, if I change the
datatype of the first field "f01" from varchar(10) to int, there is no bug!
Can I be sure that the same bug don't strike to TAdoQuery, if there is a
slight difference in select statement?
--Ville