Home » SQL ServerRSS

DSN Less Connection String format

Hi

I have able to connect the Access database using ODBC Connection in X64 OS.

For connection i have used the following code :

 

CString strDBDriver = _T("ODBC;Provider=MSDASQL;Driver={Microsoft Access Driver (*.mdb, *.accdb)};UID=NULL;PWD=NULL;");

CString strDBPath  = _T("dbq=C:\\TestDB\\TestDatabase.mdb");

Cstring strConnPath = strDBDriver + strDBPath;

CDatabase pDB;

try

{

pDB.OpenEx(strConnPath, CDatabase::noOdbcDialog)

}

---------

I can connect the database and perform my operations. Now, the problem is on closing or exit of my application following warning is displayed in DEBUG mode.

Warning: ODBC Success With Info, _CrtDbgReport: String too long or IO Error_CrtDbgReport: String too long or IO Error_CrtDbgReport: String too long or IO ErrorState:S1000,Native:63,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]

_CrtDbgReport: String too long or IO ErrorState:01S00,Native:8,Origin:[Microsoft][ODBC Microsoft Access Driver]

 

On searching, i found that ODBC error 01S00 means , supplying of wrong connection string info.

So, what is the exact connection info string for connecting the database. Can anybody help on this ?

Thanks...

Anur

 

 

 

1 Answer Found

 

Answer 1

Firstly you are using CDatabase class, which is strictly ODBC based MFC class.

Your connection  string is effectively:

"ODBC;Provider=MSDASQL;Driver={Microsoft Access Driver (*.mdb, *.accdb)};UID=NULL;PWD=NULL;dbq=C:\\TestDB\\TestDatabase.mdb"

You don't need this token, since it only applies to OLEDB:

Provider=MSDASQL;

You also don't need UID and PWD for Access, unless your user and password are NULL (which makes no sense).  If they are really blank, you would say:  UID=;PWD=;

Hence this is minimal connection string:

"ODBC;Driver={Microsoft Access Driver (*.mdb, ,.accdb)};dbq=C:\\TestDB\\TestDatabase.mdb"

 

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter