日期:2014-05-18 浏览次数:20541 次
// TODO: Add extra initialization here AfxOleInit(); _ConnectionPtr m_pConnection; if (FAILED(m_pConnection.CreateInstance("ADODB.Connection"))) { AfxMessageBox("Create Instance failed!"); return FALSE; } _bstr_t connectionStr="Driver={SQL Server};Server=(local);Database=Sales_datebase;UID=txg;PWD=703003659txg"; HRESULT rs; rs=m_pConnection->Open(connectionStr,"","",adModeUnknown); if (rs) { MessageBox(_T("连接失败!")); }