Article View: borland.public.cppbuilder.database.ado
Article #5275Re: Null string parameters and BDE TParams
From: Arnie Mauer
Date: Thu, 28 Jun 2001 12:43
Date: Thu, 28 Jun 2001 12:43
84 lines
4033 bytes
4033 bytes
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
"Formentz" <francesco@leotron.com> wrote in message news:3b3a0044_1@dnews...
> Hi all,
> I followed the discussion 'Empty String Parameters are Illegal in ADO?' of
> 8th june and saw how to prevent the error :
> 'Parameter object is improperly defined. Inconsistent or incomplete
> information was provided.'
>
> But then I tried to run the program on another machine, that probably has
> different version of MDAC (I have 2.1) and the error still pops up.
> Since I started to work with ADO I had problems with the buggy TParameters
> class, why didn't Borland keep the strong and easy to use TParams class,
> with all the AsString, AsInteger ... properties? It worked so well ...
:-(((
>
> TIA
> Ciao
> Formentz
>
>
Technical Details
Message-ID:
<3b3b2673$1_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!east1.newsfeed.sprint-canada.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3b3a0044_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 05:56:41 PST From: "Arnie Mauer" <arnie@marketexpert.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3b3a0044_1@dnews> Subject: Re: Null string parameters and BDE TParams Date: Thu, 28 Jun 2001 08:43:31 -0400 Lines: 86 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: <3b3b2673$1_2@dnews> X-Trace: dnews 993732211 209.140.211.97 (28 Jun 2001 05:43:31 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!east1.newsfeed.sprint-canada.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews