Thread View: comp.lang.pascal.delphi.databases
5 messages
5 total messages
Started by Nick Ring
Mon, 01 May 2000 00:00
Exchanging Advantage And BDE Tables during run-time
Author: Nick Ring
Date: Mon, 01 May 2000 00:00
Date: Mon, 01 May 2000 00:00
16 lines
1394 bytes
1394 bytes
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
Re: Exchanging Advantage And BDE Tables during run-time
Author: Paul Ferrara
Date: Mon, 01 May 2000 00:00
Date: Mon, 01 May 2000 00:00
26 lines
1709 bytes
1709 bytes
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. 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
Re: Exchanging Advantage And BDE Tables during run-time
Author: M.H. Avegaart
Date: Mon, 01 May 2000 00:00
Date: Mon, 01 May 2000 00:00
33 lines
2166 bytes
2166 bytes
Yes, and if you want to store your TTable or TAdsTable in a common variable use type TDataSet. "Paul Ferrara" <paul@nospam.columbusoft.com> schreef in bericht 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. > > 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 > >
Re: Exchanging Advantage And BDE Tables during run-time
Author: 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
>
>
Re: Exchanging Advantage And BDE Tables during run-time
Author: Smola
Date: Tue, 02 May 2000 00:00
Date: Tue, 02 May 2000 00:00
20 lines
1922 bytes
1922 bytes
"Bruce Roberts" <no.junk.please.ber@attcanada.net> wrote: > >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. > Well, the code seems to be OK but the original question does not want all the complicated stuff like creating objects and all that. >> > 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?? As far as the assignement is concerned, you can assign any kind of your variable to anything, as long as you know what are you doing. I've been assigning "whoknowswhat" to TTable and TQuery. The important thing is that it is a descendant of the TDataSet. Smola -- Slowly growing deaf.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads