Click here to Skip to main content
15,892,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to connect ODBC database as follows:
C++
CDatabase m_database;
	CRecordset m_recordset; 
	CString strSQL,PlateNo;
	CString conn=(L"DRIVER=SQL Server Native Client 10.0;SERVER=.\\SQLEXPRESS;Trusted_Connection=Yes;APP=Microsoft\x00ae Visual Studio\x00ae 2010;WSID=EGGEN2;DATABASE=DB01;");
	m_database.Open(conn);
	m_recordset.m_pDatabase=&m_database;
	strSQL.Format(L"select * from NP where S.NO.=1");
	m_recordset.Open(CRecordset::forwardOnly,strSQL);
	if(m_recordset.GetRecordCount()>0)
	{
	m_recordset.GetFieldValue(L"PLATE NO",PlateNo);
	}
	m_recordset.Close();
	m_database.Close();


It gives an error "Failed to create empty document"

When i debugged it,the error i found was in the line "m_database.Open(conn);"

Pl suggest a solution
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900