 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Markus Breuer Guest
|
Posted: Sun Feb 15, 2004 7:02 pm Post subject: How to initialize ADOX from C++ Builder? |
|
|
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
|
Posted: Mon Feb 16, 2004 6:39 am Post subject: Re: How to initialize ADOX from C++ Builder? |
|
|
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 |
|
 |
|
|
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
|
|