65,184
社区成员




//stdfax.h
#import "C:\Program Files\Common Files\System\ado\msado15.dll"
no_namespace rename("EOF","adoEOF")
//banjiguanlixitong.h
public:
_connectionPtr m_pAppConn;
CString m_AppConnString;
BOOL m_bConnected;
//banjiguanlixitong.cpp
CBanjikaoqinApp::CBanjikaoqinApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
/////////////////////////////////
//////////////fkha;lhfljkakjg
m_AppConnString=_T("Driver={SQL Server};Server=127.0.0.1;")
_T("Database=master;Uid=sa;pwd=;");
m_bConnected=FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CBanjikaoqinApp object
CBanjikaoqinApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CBanjikaoqinApp initialization
BOOL CBanjikaoqinApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
HRESULT hRes;
try
{
hRes=theApp.m_pAppConn.CreateInstance(_T("ADODB.Connection"));
m_pAppConn->ConnectionTimeout=8;
hRes=m_pAppConn->Open(_bstr_t((LPCTSTR) m_AppConnString),
_T(""),_T(""),adModeUnknown);
if(SUCCEEDED(hRes))
{m_bConnected=TRUE;}
}
catch(_com_error e)
{
CString errermessage;
errormessage.Format(_T("连接数据库失败:%s"),e.ErrorMessage());
AfxMessageBox(errormessage);
return FALSE;
}
#import "....msado15.dll" rename_namespace("ADOWE") rename("EOF","EndOfFile")