连接数据库打开有问题!
在StdAfx.h中加上
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","rsEOF")
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
_CommandPtr pCmd(__uuidof(Command));
pConn->ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial
Catalog=student4;Data Source=HAO-PC\SQLEXPRESS";//打开时出现错误。这个连接字符串是从ADO获得(出现下面的错误大家帮忙看看)
pConn->Open("","","",adConnectUnspecified);
pCmd->put_ActiveConnection_variant_t((IDispatch*)pConn));
pCmd->CommandText="select * from student4";
pRst=pCmd->Execute(NULL,NULL,adCmdText);
while(!pRst->rsEOF)
{
((CListBox*)GetDlgItem(IDC_LIST1))->AddString(
(_bstr_t)pRst->GetCollect("au_lname"));
pRst->MoveNext();
}
pRst->Close();
pConn->Close();
pCmd.Release();
pRst.Release();
pConn.Release();
CoUninitialize();
还没走到open时就出现:
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\KernelBase.dll', no matching symbolic information found.
Loaded symbols for 'C:\Windows\System32\MFC42D.DLL'
Loaded symbols for 'C:\Windows\System32\MSVCRTD.DLL'
Loaded 'C:\Windows\System32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\user32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\lpk.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\usp10.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\msvcrt.dll', no matching symbolic information found.
Loaded symbols for 'C:\Windows\System32\MFCO42D.DLL'
Loaded 'C:\Windows\System32\ole32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\oleaut32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\imm32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\msctf.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\MFC42LOC.DLL', no matching symbolic information found.
Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_ec80f00e8593ece5\comctl32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\sechost.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\uxtheme.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\dwmapi.dll', no matching symbolic information found.
Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\shlwapi.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\cryptbase.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\clbcatq.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\MSADODC.OCX', no matching symbolic information found.
Loaded 'C:\Windows\System32\sxs.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\olepro32.dll', no matching symbolic information found.
Loaded 'C:\Users\hao\AppData\Roaming\TaobaoProtect\TaobaoProtectSE.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\psapi.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\shell32.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\version.dll', no matching symbolic information found.
Loaded 'C:\Windows\System32\profapi.dll', no matching symbolic information found.
不知道为什么!