Article View: borland.public.cppbuilder.database.ado
Article #1863Re: Linking Tables to an MSAccess Database in Code
From: Viatcheslav V. Vassiliev
Date: Sun, 25 Jan 2004 10:06
Date: Sun, 25 Jan 2004 10:06
95 lines
3922 bytes
3922 bytes
Database with the same name already exists.
//
// MessageId: DB_E_DUPLICATEDATASOURCE
//
// MessageText:
//
// Data source object could not be created because the named data source
already exists.
//
#define DB_E_DUPLICATEDATASOURCE ((HRESULT)0x80040E17L)
//------------------------------------------
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)
"Robert Emmons" <remmons@aurigen.com> ???????/???????? ? ???????? ?????????:
news:8ek510h1jdvdgubdq1gevn5kn0ka595vef@4ax.com...
> 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:
<4013952a@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:
<pu5t00drncdrn41hnftvesb6nviv7pjs4l@4ax.com> <400fcfe1@newsgroups.borland.com> <8ek510h1jdvdgubdq1gevn5kn0ka595vef@4ax.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-25 02:09:16 PST From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <pu5t00drncdrn41hnftvesb6nviv7pjs4l@4ax.com> <400fcfe1@newsgroups.borland.com> <8ek510h1jdvdgubdq1gevn5kn0ka595vef@4ax.com> Subject: Re: Linking Tables to an MSAccess Database in Code Date: Sun, 25 Jan 2004 13:06:12 +0300 Lines: 97 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: <4013952a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1075025194 213.234.218.42 (25 Jan 2004 02:06:34 -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