🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1663

Re: Problem using ADOConnection->OpenSchema

#1663
From: moonmike
Date: Tue, 16 Mar 2004 12:00
68 lines
2742 bytes
"Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote:
>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.
I'm found another solution for solve this problem:
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;

int bounds[] = {0,3};
OleVariant A(bounds,1, varVariant);
A.PutElement(Unassigned(),0);
A.PutElement(Unassigned(),1);
A.PutElement(Unassigned(),2);
A.PutElement(WideString("TABLE") ,3);
ADOConnection1->OpenSchema(siTables, A, EmptyParam, ADODataSet1);
}
Technical Details
Message-ID: <4056ec48$1@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-mail
References: <3fd808b7$1@newsgroups.borland.com> <3fd81217@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,dcb82e1dc41db4f2
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2004-03-16 04:09:43 PST
From: "moonmike" <moonmike@pisem.net>
Sender: "moonmike" <moonmike@pisem.net>
Reply-To: "moonmike" <moonmike@pisem.net>
Subject: Re: Problem using ADOConnection->OpenSchema
Newsgroups: borland.public.cppbuilder.database.ado
X-User-Info: 82.142.150.194     
References: <3fd808b7$1@newsgroups.borland.com> <3fd81217@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4056ec48$1@newsgroups.borland.com>
Date: 16 Mar 2004 04:00:08 -0800
X-Trace: newsgroups.borland.com 1079438408 207.105.83.66 (16 Mar 2004 04:00:08 -0800)
Lines: 69
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