Hi all,

I create a database on SQL 2005 Express edition and link it to a C++/MFC application as follows. It wont gives any compile time errors. But at run time, it gives an error. Here are details.

Link the database in OnInitDialog()

here is the code

BOOL CSRFDBDlg::OnInitDialog()
CDatabase srfDB ;
CString srfNAME ;

srfNAME = "ODBC; DSN=.SQLEXPRESS; UID=sa; PWD=sa123; DATABASE=srfdb.mdf" ;
srfDB.Open(srfNAME) ;
AfxMessageBox("ok") ;

srfDB.Close() ;

Gives the following runtime error

Data source name not found and no default driver specified

Can you guys tell me where I'm going wrong....

Yep, I'm sure that the DNS setup is correct. At the time I've tried the SQLOLEDB.1 connection. I think it can be easy to work on OLEDB, do you have any suggestion on that?

I'm really appreciate your comments....

This article has been dead for over six months. Start a new discussion instead.