🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
2 messages
2 total messages Started by Eric Archer Wed, 27 Apr 2005 16:13
Creeating MS Access database dynamically
#794
Author: Eric Archer
Date: Wed, 27 Apr 2005 16:13
4 lines
1343 bytes
I'm using BCB 6 and am fairly new at working with databases.  I've been successful at interacting with my MS Access database using ADO, but I've got an issue that I haven't found any way to solve:

If someone "accidentally" deletes the database file, I'd like the application to check for its existence (if (!FileExists("data.mdb")), and to create a new database file, regenerate the fields, and populate it with a minimum of data hardcoded in the application.  Is this possible with ADO and MS Access?  Thanks!
Re: Creeating MS Access database dynamically
#795
Author: Viatcheslav V. Vassiliev
Date: Wed, 27 Apr 2005 20:43
47 lines
2555 bytes
Import ADOX type library and execute

//strConn is connection string.

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 (for C++ Builder 6)

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

"Eric Archer" <eric.archer@noaa.gov> �������/�������� � �������� ���������: 
news:426fba1d$1@newsgroups.borland.com...
>
> I'm using BCB 6 and am fairly new at working with databases.  I've been 
> successful at interacting with my MS Access database using ADO, but I've 
> got an issue that I haven't found any way to solve:
>
> If someone "accidentally" deletes the database file, I'd like the 
> application to check for its existence (if (!FileExists("data.mdb")), and 
> to create a new database file, regenerate the fields, and populate it with 
> a minimum of data hardcoded in the application.  Is this possible with ADO 
> and MS Access?  Thanks! 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads