在WIN7系统下用VS2010工具编写了一个利用ADO连接SQL2000数据库的程序,在WIN7系统下可以正常连接数据库,但是一迁移到Server2000,或者是XP系统上,就显示不支持此接口!请问这问题怎么解决?
下面附上代码:
#import "c:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF") rename("BOF","adoBOF") 文件路径检查过,没有错误!
::CoInitialize(NULL);
_ConnectionPtr pMyConnect = NULL;
HRESULT hr = pMyConnect.CreateInstance("ADODB.Connection");
if (FAILED(hr))
{
_com_error e(hr);
AfxMessageBox(e.ErrorMessage());
return;
} sqlStr.Format(_T("Provider=SQLOLEDB;Server=%s;Database=RegionalStationData;uid=%s;pwd=%s;"), ServerName, UserName, PassWord);
try
{
pMyConnect->Open((_bstr_t)sqlStr, "", "", NULL);
}
catch (_com_error &e)
{
MessageBox(e.Description(), _T("警告"), MB_OK|MB_ICONINFORMATION);
return;
} ::CoUninitialize();
pMyConnect->Close(); /*****关闭数据库****/
pMyConnect.Release();
pMyConnect = NULL;数据库serverMFCADO
下面附上代码:
#import "c:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF") rename("BOF","adoBOF") 文件路径检查过,没有错误!
::CoInitialize(NULL);
_ConnectionPtr pMyConnect = NULL;
HRESULT hr = pMyConnect.CreateInstance("ADODB.Connection");
if (FAILED(hr))
{
_com_error e(hr);
AfxMessageBox(e.ErrorMessage());
return;
} sqlStr.Format(_T("Provider=SQLOLEDB;Server=%s;Database=RegionalStationData;uid=%s;pwd=%s;"), ServerName, UserName, PassWord);
try
{
pMyConnect->Open((_bstr_t)sqlStr, "", "", NULL);
}
catch (_com_error &e)
{
MessageBox(e.Description(), _T("警告"), MB_OK|MB_ICONINFORMATION);
return;
} ::CoUninitialize();
pMyConnect->Close(); /*****关闭数据库****/
pMyConnect.Release();
pMyConnect = NULL;数据库serverMFCADO
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货