Article View: borland.public.cppbuilder.database.ado
Article #1696Re: ADOConnection1->OpenSchema(siPrimaryKeys , Array, EmptyParam, (TADODataSet*)p_PKList);
From: Viatcheslav V. Vassiliev
Date: Thu, 08 Apr 2004 07:01
Date: Thu, 08 Apr 2004 07:01
123 lines
4190 bytes
4190 bytes
Primary keys schema has 3 restrictions (catalog, schema, name), not 4:
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 = 3;
psa = SafeArrayCreate(VT_VARIANT, 1, &rgsabound);
var.VType = VT_BSTR;
var.VOleStr = WideString("pubs"); //catalog
long ix;
ix = 0;
SafeArrayPutElement(psa, &ix, &var);
var.VType = VT_BSTR;
var.VOleStr = WideString("dbo");
var.VType = VT_EMPTY;
ix = 1;
SafeArrayPutElement(psa, &ix, &var);
var.VType = VT_BSTR;
var.VOleStr = WideString("authors"); //name of table
ix = 2;
SafeArrayPutElement(psa, &ix, &var);
// var.VType = VT_EMPTY;
// ix = 3;
// SafeArrayPutElement(psa, &ix, &var);
Array.VType = VT_ARRAY | VT_VARIANT;
Array.VArray = (TVarArray*)psa;
ADOConnection1->Connected = true;
ADOConnection1->OpenSchema(siPrimaryKeys , Array, EmptyParam, ADODataSet1);
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"John Z Fields" <jfields@wrsystems.com> �������/�������� � ��������
���������: news:4073f77d@newsgroups.borland.com...
> Please help. I have code that gets primary key information for a table.
This
> works with Oracle, but generates an error with SQL Server and Sybase.
Please
> advise if you have been able to get this to work with these vendors. Many
> thanks!
>
> The error generated is
> ---------------------------
> Error Determining catalog
> ---------------------------
> Object or provider is not capable of performing requested operation
> ---------------------------
> OK
> ---------------------------
>
> I am running SQL Server 2000, with MDAC v 2.8. I am using Borland C++
> Builder V6
>
> The code is as below.
>
>
> 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_BSTR;
> var.VOleStr = WideString("PEPCO2"); //catalog
> long ix;
> ix = 0;
> SafeArrayPutElement(psa, &ix, &var);
>
> var.VOleStr = WideString("dbo");
> ix = 1;
> SafeArrayPutElement(psa, &ix, &var);
>
> var.VOleStr = WideString(Edit1->Text); //name of table
> ix = 2;
> SafeArrayPutElement(psa, &ix, &var);
>
> var.VType = VT_EMPTY;
> ix = 3;
> SafeArrayPutElement(psa, &ix, &var);
>
> Array.VType = VT_ARRAY | VT_VARIANT;
> Array.VArray = (TVarArray*)psa;
>
>
>
> try
> {
> ADOConnection1->OpenSchema(siPrimaryKeys , Array, EmptyParam,
> (TADODataSet*)p_PKList);
> }
> catch(Exception &E)
> {
> MessageBox(NULL,
>
> --
> JOHN Z FIELDS
>
>
Technical Details
Message-ID:
<4074f8c8$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4073f77d@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,5441336403a8b7e8 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2004-04-08 00:09:31 PST From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <4073f77d@newsgroups.borland.com> Subject: Re: ADOConnection1->OpenSchema(siPrimaryKeys , Array, EmptyParam, (TADODataSet*)p_PKList); Date: Thu, 8 Apr 2004 11:01:22 +0400 Lines: 125 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: <4074f8c8$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1081407688 213.234.218.42 (8 Apr 2004 00:01:28 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail