Article View: borland.public.cppbuilder.database.ado
Article #5181Re: Null string parameters and BDE TParams
From: Formentz
Date: Thu, 28 Jun 2001 16:36
Date: Thu, 28 Jun 2001 16:36
102 lines
5138 bytes
5138 bytes
Hi Arnie,
I can see you worked hard on this, and I can see also that you are a skilled
programmer too, the idea to wrap all in subclasses is excellent!
Luckyly I thought at this possibility soon when I started my projects and
adopted something different :
I use many wrap procedures like :
void __fastcall ParamString(TDataSet * DataSet, AnsiString ParamName,
AnsiString Value);
then inside the function I do some dynamic_cast to get the right type of the
DataSet parameter and assign the parameter's value
It isn't as clean as your approach, but it does the work so well that I
changed from ODBCExpress to ADOExpress with no particular difficulties.
As I can remember you use Oracle right?
I am using SQL Server, so there must be some differences because I tried
your method and got something better than what I was doing, now the value of
the date field is 0.00.00, which I thinks is the same as 0. Now I can
workaround the ADOExpress bug and check the Value of a Date field before
displaying it (through the wrap procedures) and return NULL if the value is
0.
There is another thing that is very strange, when I do :
Parameter->Attributes << paNullable;
the value of Attributes doesn't change.
I know there should be a sort of bug in VCL with sets, and so tried with
Parameter->Attributes = TParameterAttributes()<<paNullable;
No difference, Attributes is still empty.
I hope that borland will correct these bugs because it is very frustrating
to loose much more time workarounding ADOExpress issues than building the
final application.
That's all, thank you very much Arnie for your suggestion.
Ciao
Formentz
"Arnie Mauer" <arnie@marketexpert.com> ha scritto nel messaggio
news:3b3b2673$1_2@dnews...
> Hi,
>
> I started that thread. I actually had to solve a number of problems. The
> big
> one is the conversion from BDE to ADO. Our product consists of over 700
> CPP files and 150 odd executables. The NULL string problem was just
> another wrinkle. I'l try to make a long story short.
>
> We used to use TDatabase, TQuery, TStoredProc and a few TTables. I
> created our own DB objects descended from the ADO objects to 'mask'
> almost all of the differences. For example,
> class TMyDatabase : public TADOConnection
> When doing this, I added a "ParamByName" method to TMyQuery because
> the TADOQuery doesn't have one (it has q->Parameters->ParamByName()
> instead).
>
> My ParamByName returns a TMyParameter *. I have added the AsWhatever
> properties to TMyParameter for compatibility with the BDE code. When
> doing so, I took care of the NULL problem. Don't know if it's the correct
> way, but it seems to work. Also added methods to set NULL integers, date,
> etc. I 'hid' the TParameter->Value property by making it private in the
> TMyParameter object. Some code excerpts:
>
>
////////////////////////////////////////////////////////////////////////////
> /
> //
> // TRMSParameter class
> //
>
////////////////////////////////////////////////////////////////////////////
> /
> class PACKAGE TRMSParameter : public TParameter
> {
> private:
> Variant Value;
> protected:
> void __fastcall SetInt( const int AnInt )
> {TParameter::Value = AnInt;}
> ...
> void __fastcall SetAnsiString( const Variant AString )
> {
> Attributes << paNullable;
> TParameter::Value = AnsiString( AString );
> if ( Size == 0 ) Size = 1;
> }
> ...
> public:
> __fastcall TRMSParameter( TCollection * c ) :
> TParameter( c ) {};
> void __fastcall NullDate( void )
> {Attributes << paNullable;
> DataType = ftDateTime;
> TParameter::Value = Null;
> Size = 1;}
> ...
> __property const int AsInteger = {write=SetInt};
> __property const TDateTime AsDate = {write=SetDate};
> ...
> };
>
> I don't know if this helps or not, but may at least give you some ideas.
>
> Regards,
> -Arnie
>
Technical Details
Message-ID:
<3b3b5bff_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3b3a0044_1@dnews> <3b3b2673$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,5c5b2950523eeb73 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-06-28 09:43:18 PST From: "Formentz" <francesco@leotron.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3b3a0044_1@dnews> <3b3b2673$1_2@dnews> Subject: Re: Null string parameters and BDE TParams Date: Thu, 28 Jun 2001 18:36:05 +0200 Lines: 105 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 62.122.20.186 Message-ID: <3b3b5bff_1@dnews> X-Trace: dnews 993745919 62.122.20.186 (28 Jun 2001 09:31:59 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews