Thoughts from Dan Miser RSS 2.0
 Tuesday, April 05, 2005
Here's an interesting change between Delphi 6 and Delphi 2005 in the VCL. Take the following code snippet where SQLQuery1.SQLConnection = nil:
SQLQuery1.SQL.Text := 'select * from MyTable where ID = :ID';
SQLQuery1.Params.ParamByName('ID').DataType := ftInteger;

In Delphi 6, everything works fine. In Delphi 2005, TSQLQuery.QueryChanged has been updated to use TSQLQuery.SetParamsFromSQL internally. This means that if you don't have a SQLConnection assigned when updating the query text, then the params will be cleared. This means that an exception will be thrown when trying to do the ParamByName call.

I'm not sure that this would qualify as a bug, per se, but it definitely changes your application's behavior when all of these circumstances are present.

Tuesday, April 05, 2005 2:24:00 PM (Central Standard Time, UTC-06:00)  #    Comments [1] -
Delphi
Tracked by:
http://9nf-information.info/40651007/index.html [Pingback]
http://9nl-information.info/09748007/dvd-avi.html [Pingback]
http://9nk-information.info/50986723/amherst-ma-high-school.html [Pingback]
http://9ng-information.info/30745531/index.html [Pingback]
http://9nd-information.info/96350108/bar-furniture-in-new-york.html [Pingback]
http://9nt-information.info/28943843/index.html [Pingback]
http://9nd-information.info/76941445/index.html [Pingback]
http://9nw-information.info/36494993/cayman-islands-import-duty-on-cars.html [Pingback]
http://9nr-information.info/64502063/index.html [Pingback]
http://9na-information.info/26029263/index.html [Pingback]
http://9nv-information.info/90587537/index.html [Pingback]
http://9nk-information.info/05144620/index.html [Pingback]
http://9qa-information.info/43043755/index.html [Pingback]
http://9oy-information.info/63721203/index.html [Pingback]
http://9oi-information.info/27723334/index.html [Pingback]
http://9oq-information.info/75842594/index.html [Pingback]
http://9oa-information.info/91284871/index.html [Pingback]
http://9qr-information.info/64504934/sigle-ranma.html [Pingback]
http://9oa-information.info/89446718/index.html [Pingback]
http://9qe-information.info/42404086/index.html [Pingback]
http://9rg-information.info/60911499/index.html [Pingback]
http://9rm-information.info/37595656/index.html [Pingback]
http://9rw-information.info/23857285/index.html [Pingback]
http://9rd-information.info/90292263/stock-fraud-internet-statistics.html [Pingback]
http://9rv-information.info/93756569/index.html [Pingback]
http://9rr-information.info/06701952/index.html [Pingback]
http://9sf-information.info/36846879/index.html [Pingback]
http://9uaei-le-informazioni.info/41312688/index.html [Pingback]
http://9uafp-le-informazioni.info/64778978/index.html [Pingback]
http://9uaej-le-informazioni.info/30984175/index.html [Pingback]
http://9uafc-le-informazioni.info/92591625/index.html [Pingback]
http://9uafr-le-informazioni.info/33138635/index.html [Pingback]
http://9uaea-le-informazioni.info/94492610/index.html [Pingback]
http://9uafb-le-informazioni.info/52489712/ginocchiate-neo-coglione.html [Pingback]
http://9uaed-le-informazioni.info/50563026/index.html [Pingback]
http://9uafe-le-informazioni.info/73542180/pes-6-aggiornato-pc.html [Pingback]
http://9uaeg-le-informazioni.info/78980067/index.html [Pingback]
http://9uaho-le-informazioni.info/41278186/index.html [Pingback]
http://9uaga-le-informazioni.info/52367840/index.html [Pingback]
http://9uahb-le-informazioni.info/02798811/index.html [Pingback]
http://9uahm-le-informazioni.info/78996257/index.html [Pingback]
http://9uagb-le-informazioni.info/17070435/industria-tessile.html [Pingback]
http://9uahk-le-informazioni.info/36142533/index.html [Pingback]
http://9uahn-le-informazioni.info/64944926/index.html [Pingback]
http://9uagp-le-informazioni.info/01114495/lander-caravan.html [Pingback]
http://9uagm-le-informazioni.info/90013212/index.html [Pingback]
Thursday, April 07, 2005 11:34:00 AM (Central Standard Time, UTC-06:00)
I've had some problems with dbExpress vs. SQL Server in D2005 too.



I have a TSQLStoredProc, a DataSetProvider, a ClientDataSet and a DataSource.



The Proc takes a TSQLTimeStamp input parameter.



I've always written code like this in D7 when I need to refresh my data in response to a parameter change:



procOrdersSinceDate.ParamByName('@date').AsSQLTimeStamp := DateTimeToSQLTimeStamp(DateTimePicker1.Date);



cdsOrdersSinceDate.Refresh;



This works just fine in D7, but in D2005 it only works the first time (every other refresh after this returns exactly the same data even though the DateTimePicker changes).



The reason is that it seems that every Refresh of the ClientDataSet repopulates the Params of the TSQLStoredProc with its own values overwriting the new value I just set. If I write this code instead it works as expected:



if cdsOrdersSinceDate.Active then

begin

cdsOrdersSinceDate.Params.ParamByName('@date').AsSQLTimeStamp :=

DateTimeToSQLTimeStamp(DateTimePicker1.Date);



cdsOrdersSinceDate.Refresh;

end

else

begin

procOrdersSinceDate.ParamByName('@date').AsSQLTimeStamp :=

DateTimeToSQLTimeStamp(DateTimePicker1.Date);



cdsOrdersSinceDate.Open;

end;



(Sorry about the formatting, the comments editing window on this blog was *really* small in FireFox).



I hope this gets fixed in a patch or something soon as I'm not very interested in changing all my code because of this new behavior.

Tom Reiertsen
Comments are closed.
Navigation
Archive
<October 2008>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 310
This Year: 25
This Month: 1
This Week: 0
Comments: 605
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)