MFC小例子-ADO连接SqlServer
时间:2021-07-01 10:21:17
帮助过:20人阅读
hpp头文件里导入ADO
//导入ADO动态链接库
#import
"C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename(
"EOF",
"adoEOF")
//cpp文件OnInitDialog()里初始化ADO
//初始化ADO
HRESULT hr;
try
{
hr =
CoInitialize(NULL);
//检查初始化是否成功
if (SUCCEEDED(hr))
{
AfxMessageBox("初始化ADO COM成功!");
}
else
{
AfxMessageBox("初始化ADO COM失败!");
}
}
catch (_com_error e)
{
CString errormessage;
errormessage.Format("%s"), e.ErrorMessage();
AfxMessageBox(errormessage);
}
MFC小例子-ADO连接SqlServer
标签:catch dll import for name dialog cstring files code