Article View: comp.lang.pascal.delphi.databases
Article #199Re: Exchanging Advantage And BDE Tables during run-time
From: Bruce Roberts
Date: Mon, 01 May 2000 00:00
Date: Mon, 01 May 2000 00:00
92 lines
3973 bytes
3973 bytes
"Paul Ferrara" <paul@nospam.columbusoft.com> wrote in message
news:8ej96l02qr0@news2.newsguy.com...
> I think you're going to have to change the DataSet property of all your
> DataSources. I can't think of a way to do that at run-time without if
> statements.
I'm not sure about what do to at design time (possibly a tDataSet descendant
whoose constructor redirected the construction to the appropriate
BDE/Advantage constructor), but at run time the following should work.
type tForm1 = class (tForm)
. . .
private
fMyDataSet : tDataSet;
. . .
end;
procedure tForm1.FormCreate (Sender : tObject);
begin
if UsingBDE {you'll have to work this one out}
then begin
fMyDataSet := tTable.Create (Self);
{assign SessionName, DatabaseName, TableName and other BDE required
properties}
end
else begin {assuming only two table types}
fMyDataSet := tADSTable.Create (Self);
{assign the Advantage required properties}
end;
{hook the dataset to the datasource}
DataSource1.DataSet := fMyDataSet;
fMyDataSet.Open;
end;
Of course one has to include both the BDE and Advantage db engine in the
release. (Also DBTables and the Advantage equivalent(s) have to be in the
Implementation section Uses clause.) I don't know about Advantage, but
AFAIR, DBTables has an initialization section does some work with sessions
but I can't recall if it ends up starting the BDE or if that only occurs
when the first BDE table is openned.
At design time one might be able to work with a component whoose
construction looked something like:
class function tMyDataSet.NewInstance : tObject;
begin { override so that no memory is allocated }
//
end;
constructor tMyDataSet.Create (anOwner : tComponent);
begin
if UsingBDE
then Self := tMyDataSet (tTable.Create (anOwner))
else Self := tMyDataSet (tADSTable.Create (anOwner));
end;
Other than known that this compiles, (and with a very simple test works), I
really don't know all the ramafications of using it. So caution would be
advised.
>
> Paul / ColumbuSoft
> www.columbusoft.com
>
>
> Nick Ring <nring@NOSPAM.smf.com.au> wrote in message
> news:390cccae.6779618@postoffice...
> > Hello,
> >
> > What I would like to do is the following (in a nutshell) : Depending
> > if I'm running on a local machine or not, I would like to use BDE's
> > TTable (if running on a local machine), otherwise use Advantage's
> > TAdsTable.
> >
> > How ever, I don't want to use a large amount of IF statements all
> > through my code to figure out if I'm using a TTable or a TAdsTable.
> >
> > Is there a way to have the table I'm using (be it a TTable or a
> > TAdsTable) assigned to a single variable and use it with out having to
> > figure out what type it is before using it??
> >
> > Thanks for any help in advance,
> > Nick
>
>
Technical Details
Message-ID:
<j1jP4.34288$Xk2.126682@tor-nn1.netcom.ca>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<390cccae.6779618@postoffice> <8ej96l02qr0@news2.newsguy.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ffff5,d54235570ec33841 X-Google-Attributes: gidffff5,public X-Google-Thread: f8256,d54235570ec33841 X-Google-Attributes: gidf8256,public X-Google-Thread: 109d99,d54235570ec33841 X-Google-Attributes: gid109d99,public From: "Bruce Roberts" <no.junk.please.ber@attcanada.net> Subject: Re: Exchanging Advantage And BDE Tables during run-time Date: 2000/05/01 Message-ID: <j1jP4.34288$Xk2.126682@tor-nn1.netcom.ca> X-Deja-AN: 617913358 References: <390cccae.6779618@postoffice> <8ej96l02qr0@news2.newsguy.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Complaints-To: abuse@netcom.ca X-Trace: tor-nn1.netcom.ca 957201615 142.194.175.79 (Mon, 01 May 2000 13:20:15 EDT) Organization: Roberts Browne Limited X-MSMail-Priority: Normal Reply-To: "Bruce Roberts" <no.junk.please.ber@attcanada.net> NNTP-Posting-Date: Mon, 01 May 2000 13:20:15 EDT Newsgroups: comp.lang.pascal.delphi.databases,borland.public.delphi.thirdparty-tools,comp.lang.pascal.delphi.components.misc