🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Creating MS Access Database (revisited)

#1974
From: Viatcheslav V. Vassiliev
Date: Thu, 08 Jan 2004 15:24
69 lines
2976 bytes
Import ADOX type library and execute

Adox_tlb::TCOM_Catalog cat = CoCatalog::Create();
 cat->Create(strConn.c_bstr());

or

  CatalogPtr cat = CoCatalog::Create();
  cat->Create(strConn);


You may also need to add

#include <comobj.hpp>

namespace System
{
 void __fastcall CheckSafecallResult(HRESULT hr)
 {
  OleCheck(hr);
 }
}

All strings should be declared as WideString, not as AnsiString.

CoInitialize()/CoUninitialize() - do not call them, just include ComObj
unit. They are needed only in dlls.

//------------------------------------------
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)

"Pat" <pat-rizio@libero.it> ???????/???????? ? ???????? ?????????:
news:3ffd3ee0@newsgroups.borland.com...
> Hi,
> looking the past posts I learned how I can create a new linked-table in
> an existing MS Access database, using ADO components and SQL commands.
> Now I'm trying to understand how I can create a new MS Access database,
> so could you please explaine better the source code you post?
>
>  > I'm creating an MS Access database with:
>  >
>  > Variant Catalog;
>  > Variant Connection;
>  > CoInitializeEx(NULL, COINIT_MULTITHREADED);
>  > Catalog=Variant::CreateObject("ADOX.Catalog");
>  > Catalog.Exec(Function("Create") << strConnectionString);
>  > Connection = Catalog.Exec(PropertyGet("ActiveConnection"));
>  > ...
>  > Connection.Exec(Function("Close"));
>  > CoUninitialize();
>
> In strConnectionString I put yhe following:
> "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Dource=db.mdb;Mode=ReadWrite|Share Deny None";
>
> but BCB6 give me a memory error when I run the program, even if it
> create the MS Access database.
>
> What's the meaning of
>  > CoInitializeEx(NULL, COINIT_MULTITHREADED);
>
> because I don't found anything about it in the BCB6 guide.
> Thanks for the answer.
> Pat
>
Technical Details
Message-ID: <3ffd7a14@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: <DlNlsBA9AB8$Iwut@courtlands.demon.co.uk> <3ffd3ee0@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,1386b963f53820e2
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2004-01-08 07:46:49 PST
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <DlNlsBA9AB8$Iwut@courtlands.demon.co.uk> <3ffd3ee0@newsgroups.borland.com>
Subject: Re: Creating MS Access Database (revisited)
Date: Thu, 8 Jan 2004 18:24:13 +0300
Lines: 71
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: <3ffd7a14@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1073576468 213.234.218.42 (8 Jan 2004 07:41:08 -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