BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to initialize ADOX from C++ Builder?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Markus Breuer
Guest





PostPosted: Sun Feb 15, 2004 7:02 pm    Post subject: How to initialize ADOX from C++ Builder? Reply with quote



My goal is to create an empty .mdb database. The msadox.dll is allready
imported as type library into my project. I tried two ways to create the
empty mdb:

1.) Placed to ADOXCatalog from the ActiveX pane in a formular. But when
creating the mdb an access violation occurs.

ADOXCatalog1->Create( ... ); // access violation, same call as below

2.) I created the Catalog myself by executing following code:

_Catalog* Catalog = 0;
_di_IInterface mif = CreateComObject(
Sysutils::StringToGUID("ADOX.Catalog") );
mif->QueryInterface( &Catalog );

AnsiString bs =
"Provider=Microsoft.Jet.OLEDB.4.0;"
"Data Source='D:\sample.mdb';"
"Jet OLEDB:Engine Type=5";

wchar_t buffer[8192];
bs.WideChar(buffer,sizeof(buffer));
Catalog->Create(buffer); // here is the access violation!!!

What i am doing wrong?
Are there any prerequisites, which my project should have?

regards, markus



Back to top
Viatcheslav V. Vassiliev
Guest





PostPosted: Mon Feb 16, 2004 6:39 am    Post subject: Re: How to initialize ADOX from C++ Builder? Reply with quote



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.

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

"Markus Breuer" <markus.breuer (AT) gmx (DOT) de> ???????/???????? ? ????????
?????????: news:c0ofnp$198cnc$1 (AT) ID-164478 (DOT) news.uni-berlin.de...
Quote:
My goal is to create an empty .mdb database. The msadox.dll is allready
imported as type library into my project. I tried two ways to create the
empty mdb:

1.) Placed to ADOXCatalog from the ActiveX pane in a formular. But when
creating the mdb an access violation occurs.

ADOXCatalog1->Create( ... ); // access violation, same call as below

2.) I created the Catalog myself by executing following code:

_Catalog* Catalog = 0;
_di_IInterface mif = CreateComObject(
Sysutils::StringToGUID("ADOX.Catalog") );
mif->QueryInterface( &Catalog );

AnsiString bs =
"Provider=Microsoft.Jet.OLEDB.4.0;"
"Data Source='D:\sample.mdb';"
"Jet OLEDB:Engine Type=5";

wchar_t buffer[8192];
bs.WideChar(buffer,sizeof(buffer));
Catalog->Create(buffer); // here is the access violation!!!

What i am doing wrong?
Are there any prerequisites, which my project should have?

regards, markus






Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.