| | |
Run time error on my SQL database
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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
Gives the following runtime error
Can you guys tell me where I'm going wrong....
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
c++ Syntax (Toggle Plain Text)
BOOL CSRFDBDlg::OnInitDialog() { CDatabase srfDB ; CString srfNAME ; srfNAME = "ODBC; DSN=.SQLEXPRESS; UID=sa; PWD=sa123; DATABASE=srfdb.mdf" ; srfDB.Open(srfNAME) ; if(srfDB.IsOpen()) { AfxMessageBox("ok") ; } srfDB.Close() ; }
Gives the following runtime error
C++ Syntax (Toggle Plain Text)
Data source name not found and no default driver specified
Can you guys tell me where I'm going wrong....
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
hmm, are you calling that ' open' function the right way?
source: http://msdn2.microsoft.com/en-us/lib...dw(VS.80).aspx
try calling it like:
regards Niek
source: http://msdn2.microsoft.com/en-us/lib...dw(VS.80).aspx
try calling it like:
C++ Syntax (Toggle Plain Text)
CDatabase srfDB ; srfDB.Open( _T( ".SQLEXPRESS" ), FALSE, FALSE, _T( "UID=sa; PWD=sa123; DATABASE=srfdb.mdf" ));
regards Niek
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....
I'm really appreciate your comments....
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
![]() |
Similar Threads
- Run-time error '5' (Windows NT / 2000 / XP)
- Run-Time Error 424 (Visual Basic 4 / 5 / 6)
- Run-time Error when printing Array Contents. (C)
- "Run time error, do you wish to debug?" (Web Browsers)
- Run-Time Error..? (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Question
- Next Thread: Double Returning 1.#INF
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






