Article View: borland.public.cppbuilder.database.ado
Article #2028Re: Problem using ADOConnection->OpenSchema
From: Viatcheslav V. Vassiliev
Date: Fri, 12 Dec 2003 07:51
Date: Fri, 12 Dec 2003 07:51
157 lines
6325 bytes
6325 bytes
DataSet should not be prepared, just create it is enough. Replace
ADOConnection1->OpenSchema(siTables, Array, EmptyParam, ADODataSet1);
with
ADOConnection1->OpenSchema(siTables, EmptyParam, EmptyParam, ADODataSet1);
and you should get all tables and views. You may also specify restrictions -
restrictions is array of variants and meaning of values is schema-specific -
look OpenSchema help for details.
With "VIEW" schema should be filled with views, if may replace "VIEW" with
"TABLE" to get list of tables, "SYSTEM TABLE" to get list of system tables,
there may be other values such as "LINK TABLE" for linked table in Access.
For other schemas there are other restrictions - for example, siColumns
schema may get schema for all columns in database or be restricted to
columns of one table. My example just shows how to correct set parameters
(EmptyParam instead of Unassigned and how to fill array of restrictions).
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi + ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Daniel Stevenson" <d.stevenson@ocreage.com.au> �������/�������� � ��������
���������: news:3fd8e984$1@newsgroups.borland.com...
> The good thing is that your code compiles and executes without any
problems,
> the bad news is that I don't know how to retrieve any information.
>
> I was assuming that the ADODataSet1 would hold all the information
returned
> from the OpenSchema call, but my dataset is empty.
>
> Can you shed some light on how the ADODataSet1 is to be initialised and
also
> how to retreive information once the open schema function has been
executed?
> ....sorry for being so dumb
>
> I am currently initialising the ADODataSet1 as seen below
>
> TADODataSet* ADODataSet1 = new TADODataSet(NULL);
> std::auto_ptr<TADODataSet> auto_dataSet(ADODataSet1);
>
>
> and also just to ensure I'm on the right track, the function below is
meant
> to return all the table names from within the ADOConnection. Can you also
> explain what "View" is meant to represent, from what I can gather it is a
> 'TABLE_TYPE' associated with the siTables? should I be replacing this
with
> one of my table names?
>
> ...as you can tell I'm quite confused with how to properly use this
> function.
>
> Thanks for your patience
>
>
> "Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote in message
> news:3fd81217@newsgroups.borland.com...
> > Here is the code to enumerate views in MS SQL Server but it shows what
you
> > need.
> >
> > void __fastcall TForm1::Button1Click(TObject *Sender)
> > {
> > ADOConnection1->ConnectionString = WideString("Provider=SQLOLEDB;"
> > "Integrated security=SSPI;Initial catalog=pubs");
> > ADOConnection1->Connected = true;
> >
> > OleVariant EmptyParam;
> > EmptyParam.VType = VT_ERROR;
> > EmptyParam.VError = DISP_E_PARAMNOTFOUND;
> >
> > SAFEARRAY FAR* psa = NULL;
> > SAFEARRAYBOUND rgsabound;
> > OleVariant var;
> > OleVariant Array;
> > rgsabound.lLbound = 0;
> > rgsabound.cElements = 4;
> >
> > psa = SafeArrayCreate(VT_VARIANT, 1, &rgsabound);
> > var.VType = VT_EMPTY;
> >
> > long ix;
> > ix = 0;
> > SafeArrayPutElement(psa, &ix, &var);
> >
> > ix = 1;
> > SafeArrayPutElement(psa, &ix, &var);
> >
> > ix = 2;
> > SafeArrayPutElement(psa, &ix, &var);
> >
> > var.VType = VT_BSTR;
> > var.VOleStr = WideString("VIEW");
> > ix = 3;
> > SafeArrayPutElement(psa, &ix, &var);
> >
> > Array.VType = VT_ARRAY | VT_VARIANT;
> > Array.VArray = (TVarArray*)psa;
> >
> > ADOConnection1->OpenSchema(siTables, Array, EmptyParam, ADODataSet1);
> > }
> >
> > //------------------------------------------
> > Regards,
> > Vassiliev V. V.
> > http://www.managed-vcl.com - using .Net objects in Delphi + ADO.Net
> > http://www.oledbdirect.com - The fastest way to access MS SQL Server,
> > MS Jet (Access) and Interbase (through OLEDB)
> >
> > "Daniel Stevenson" <d.stevenson@ocreage.com.au> �������/�������� �
> ��������
> > ���������: news:3fd808b7$1@newsgroups.borland.com...
> > > I'm trying to return some information using the openschema as seen
below
> > >
> > >
> > > Variant tvars[3] = { Unassigned(), Unassigned(), "tablename" };
> > >
> > > TADODataSet* dataSet = new TADODataSet(NULL);
> > > std::auto_ptr<TADODataSet> auto_dataSet(dataSet);
> > >
> > > ADOConnection->OpenSchema(siPrimaryKeys , VarArrayOf(tvars, 2),
> NULL,
> > > dataSet);
> > >
> > > //where tablename is the name of one of the tables within my
> database
> > >
> > >
> > > This seems to compile ok but when it is executed it returns the
> following
> > > error
> > >
> > > "Arguments are of the wrong type, are out of acceptable range, or
> are
> > in
> > > conflict with one another."
> > >
> > > I unfortunately don't know a lot about OpenSchema and was using
someone
> > > else's code they posted earlier.
> > >
> > > Any Help as to where I am going wrong would be greatly appreciated.
> > >
> > >
> >
> >
>
>
Technical Details
Message-ID:
<3fd98c01$2@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fd808b7$1@newsgroups.borland.com> <3fd81217@newsgroups.borland.com> <3fd8e984$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,dcb82e1dc41db4f2 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-12-12 01:39:51 PST From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3fd808b7$1@newsgroups.borland.com> <3fd81217@newsgroups.borland.com> <3fd8e984$1@newsgroups.borland.com> Subject: Re: Problem using ADOConnection->OpenSchema Date: Fri, 12 Dec 2003 10:51:51 +0300 Lines: 159 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 213.234.218.42 Message-ID: <3fd98c01$2@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1071221761 213.234.218.42 (12 Dec 2003 01:36:01 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail