try
{
m_pConnection.CreateInstance("ADODB.Connection");
char chSize[MAX_PATH];
CString strPath;
::GetModuleFileName(NULL, chSize, MAX_PATH);
strPath = chSize;
int nIndex = strPath.ReverseFind('\\');
strPath = strPath.Left(nIndex) + _T("\\data\\shujuku.mdb");
CString strConnect;
strConnect.Format(_T("Provider = Microsoft.Jet.OLEDB.4.0;\
Data Source = %s;\
Persist Security Info = False"),
strPath);
// CString strConnect = "DRIVER = {Microsoft Access Driver (*.mdb)};\
uid = ;pwd = ; DBQ = shujuku.mdb;";
m_pConnection->Open((_bstr_t)strConnect, "", "", adModeUnknown);
if(m_pConnection->State != adStateOpen)
{
CString strError;
strError.Format(_T("打开数据库文件%s失败!"), strPath);
AfxMessageBox(strError);
}
}
catch(_com_error e)
{
AfxMessageBox("连接数据库失败,请检查数据库路径是否正确!");
}
上面是我连接access数据库写的,总是提示("连接数据库失败,请检查数据库路径是否正确!");
error: the applicationg request runtime terminate in a unusual way.....
麻烦大家帮忙看看,谢谢了先