[求助]为什么我加载数据库失败?
CoInitialize(NULL);m_pConnection.CreateInstance(__uuidof(Connection));
m_pRecordset.CreateInstance(__uuidof(Recordset));
CString strvalue;
CString string="select * from stuinfo";
m_pConnection->ConnectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ysu;Server=COMMLAB-A7B54A4\SQLEXPRESS";
try
{ m_pConnection->Open("","","",adConnectUnspecified);
m_pRecordset=m_pConnection->Execute(_bstr_t(string),NULL,adCmdText);
//m_pRecordset->Open(_variant_t(string),(IDispatch *)m_cnn,adOpenDynamic,adLockOptimistic,adCmdText);}
catch(_com_error e)
{
AfxMessageBox("连接失败");
}
m_pConnection->Close();
m_pRecordset->Close();
}
CoUninitialize();
其中, m_pConnection和m_pRecordset已经定义为全局变量!其中加黑的字段Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ysu;Server=COMMLAB-A7B54A4\SQLEXPRESS"是用ado控件时建立四步,系统自动生成的,我用的是SQL SEVER 2005
她总是显示:the application has requested the Runtime to terminate it in an unusual way,please contact the application's support team for more information!
有人知道这是为什么吗?请告诉我,谢谢了!