[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Using SQLConfigDataSource with CREATE_DB to Create *.mdb File

Tom Bruce

12/23/2002 1:27:00 PM

I have been using the following code to create a new *.mdb Access database:

**********************************************************
BOOL error;
strstream newDataSource;
char newDatabasePath[260];
char newDatabaseName[260];

/******************/
/* Initialize parameters */
/******************/
strcpy(newDatabasePath, "C:\\temp\\");
strcpy(newDatabaseName, "TestDatabase.mdb");
newDataSource.rdbuf()->freeze(0);
newDataSource.seekp(0);
newDataSource << "CREATE_DB="<< newDatabasePath
<< newDatabaseName << " General"
<< ends << ends;

/************************/
/* Create the new database file*/

/************************/
error = SQLConfigDataSource(NULL,
ODBC_ADD_DSN,
"Microsoft Access Driver
(*.mdb)",
newDataSource.str());
**********************************************************

This code works just fine except if the NewDatabasePath happens to
contain a space. For example if I change "C:\\temp\\" to "C:\\temp temp\\"
then the code fails. I have made sure that the directory does exist. I
have
tried "C:\\temp%20temp\\" and it also fails. Does anyone have another
suggestion to get this working correctly?

Thanks in advance
Tom


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.g...).
Version: 6.0.431 / Virus Database: 242 - Release Date: 12/17/2002