🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #5182

Re: Null string parameters and BDE TParams

#5182
From: Arnie Mauer
Date: Thu, 28 Jun 2001 19:29
127 lines
5945 bytes
I chose to create the objects in order to come as close to BDE object
methods and properties as possible, since we have thousands of lines
of code to convert.  Also, I added them to the "Data Access" page so
they could continue to be used at design-time on forms.

You are absolutely correct about "Parameter->Attributes << paNullable;"
I was dumb enough to believe the documentation - especially when the
help referred to "psNullable" instead of "paNullable".  You'd think I would
know better after using BCB for over four years now!

- Arnie

"Formentz" <francesco@leotron.com> wrote in message news:3b3b5bff_1@dnews...
> 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: <3b3b8580$1_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3b3a0044_1@dnews> <3b3b2673$1_2@dnews> <3b3b5bff_1@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 12:36:26 PST
From: "Arnie Mauer" <arnie@marketexpert.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3b3a0044_1@dnews> <3b3b2673$1_2@dnews> <3b3b5bff_1@dnews>
Subject: Re: Null string parameters and BDE TParams
Date: Thu, 28 Jun 2001 15:29:04 -0400
Lines: 129
Organization: VRMS
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 209.140.211.97
Message-ID: <3b3b8580$1_1@dnews>
X-Trace: dnews 993756544 209.140.211.97 (28 Jun 2001 12:29:04 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews