Article View: borland.public.cppbuilder.database.ado
Article #1860Re: Linking Tables to an MSAccess Database in Code
From: Robert Emmons
Date: Sat, 24 Jan 2004 20:20
Date: Sat, 24 Jan 2004 20:20
72 lines
3069 bytes
3069 bytes
On Thu, 22 Jan 2004 16:25:42 +0300, "Viatcheslav V. Vassiliev"
<support@oledbdirect.com> wrote:
>This should help:
>
> Adox_tlb::Property* ppvObject;
> OLECHECK(tbl->Properties->get_Item(WideString("Jet OLEDB:Create Link",
>(Adox_tlb::Property**)&ppvObject));
> ppvObject->Value = ...
>
The code below all compiles, but throws and error message when
executing "cat->Create(...)". Code:
AnsiString connectStr = "Provider=Microsoft.Jet.OLEDB.4.0;"
"Data Source=c:\\data\\HitTemp.mdb"
Adox_tlb::TCOM_Catalog cat = CoCatalog::Create();
cat->Create(WideString(connectStr));
Adox_tlb::TCOM_Table tbl = CoTable::Create();
tbl->ParentCatalog = cat;
Adox_tlb::Property *ppvObject;
Variant ppvName = "Jet OLEDB:Create Link";
Variant ppvValue = true;
ppvObject = tbl->Properties->get_Item(ppvName);
ppvObject->set_Value(ppvValue);
ppvName = "Jet OLEDB:Link Datasource";
ppvValue = "C:\\data\\HitData.mdb";
ppvObject = tbl->Properties->get_Item(ppvName);
ppvObject->set_Value(ppvValue);
ppvName = "Jet OLEDB:Link Remote Table Name";
ppvValue = "linkTest";
ppvObject = tbl->Properties->get_Item(ppvName);
ppvObject->set_Value(ppvValue);
Here is the error message:
---------------------------
HRCHECK:
---------------------------
(this->Create(ConnectString, (VARIANT*)&Connection)) Error: 80040E17
(-2147217897) @ c:\program
files\borland\cbuilder6\imports\ADOX_TLB.h/479
Press [Y]es to terminate, [N]o to continue and [C]ancel to Debug
---------------------------
Yes No Cancel
---------------------------
Here is the line 479 from ADOX_TLB.h:
OLECHECK(this->Create(ConnectString, (VARIANT*)&Connection));
Here is the entire function:
VARIANT __fastcall Create(BSTR ConnectString/*[in]*/)
{
VARIANT Connection;
OLECHECK(this->Create(ConnectString, (VARIANT*)&Connection));
return Connection;
}
As you can see, cat->Create() calls OLECHECK, so it seems unnecessary
to call it separately.
As usual, I would appreciate any suggestions?
Technical Details
Message-ID:
<8ek510h1jdvdgubdq1gevn5kn0ka595vef@4ax.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:
<pu5t00drncdrn41hnftvesb6nviv7pjs4l@4ax.com> <400fcfe1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,624e139e318cdbfb X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2004-01-24 12:39:57 PST From: Robert Emmons <remmons@aurigen.com> Newsgroups: borland.public.cppbuilder.database.ado Subject: Re: Linking Tables to an MSAccess Database in Code Date: Sat, 24 Jan 2004 15:20:35 -0500 Message-ID: <8ek510h1jdvdgubdq1gevn5kn0ka595vef@4ax.com> References: <pu5t00drncdrn41hnftvesb6nviv7pjs4l@4ax.com> <400fcfe1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 68.193.14.50 X-Trace: newsgroups.borland.com 1074975512 68.193.14.50 (24 Jan 2004 12:18:32 -0700) Lines: 73 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