Article View: borland.public.cppbuilder.database.ado
Article #2010Re: Problem using ADOConnection->OpenSchema
From: Viatcheslav V. Vassiliev
Date: Thu, 11 Dec 2003 06:39
Date: Thu, 11 Dec 2003 06:39
80 lines
3386 bytes
3386 bytes
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:
<3fd81217@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!newsfeeds-atl2!c03.atl99!news.webusenet.com!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fd808b7$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-10 23:02:31 PST From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3fd808b7$1@newsgroups.borland.com> Subject: Re: Problem using ADOConnection->OpenSchema Date: Thu, 11 Dec 2003 09:39:10 +0300 Lines: 82 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: <3fd81217@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1071125015 213.234.218.42 (10 Dec 2003 22:43:35 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!newsfeeds-atl2!c03.atl99!news.webusenet.com!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail