ado的版本

millian 2003-11-17 11:49:43
如何获得操作系统中ADO的版本?
...全文
60 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
AkiraChing 2003-11-18
  • 打赏
  • 举报
回复
void VersionX(void)
{
HRESULT hr = S_OK;

// Define string variables.
_bstr_t strCnn("driver={SQL Server};server='MySqlServer';"
"user id='MyUserId';password='MyPassword';database='pubs';");

// Define ADO object pointers.
// Initialize pointers on define.
// These are in the ADODB:: namespace.
_ConnectionPtr pConnection = NULL;

try
{
// Open connection.
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
pConnection->Open (strCnn, "", "", adConnectUnspecified);

printf("ADO Version : %s\n\n",(LPCSTR) pConnection->Version);
printf("DBMS Name : %s\n\n",(LPCSTR) (_bstr_t)
pConnection->Properties->GetItem("DBMS Name")->Value);
printf("DBMS Version : %s\n\n",(LPCSTR) (_bstr_t)
pConnection->Properties->GetItem("DBMS Version")->Value);
printf("OLE DB Version : %s\n\n",(LPCSTR) (_bstr_t)
pConnection->Properties->GetItem("OLE DB Version")->Value);
printf("Provider Name : %s\n\n",(LPCSTR) (_bstr_t)
pConnection->Properties->GetItem("Provider Name")->Value);
printf("Provider Version : %s\n\n",(LPCSTR) (_bstr_t)
pConnection->Properties->GetItem("Provider Version")->Value);
printf("Driver Name : %s\n\n",(LPCSTR) (_bstr_t)
pConnection->Properties->GetItem("Driver Name")->Value);
printf("Driver Version : %s\n\n",(LPCSTR) (_bstr_t)
pConnection->Properties->GetItem("Driver Version")->Value);
printf("Driver ODBC Version : %s\n\n",(LPCSTR) (_bstr_t)
pConnection->Properties->GetItem("Driver ODBC Version")->Value);

}

catch (_com_error &e)
{
// Notify the user of errors if any.
PrintProviderError(pConnection);
PrintComError(e);
}

if (pConnection)
if (pConnection->State == adStateOpen)
pConnection->Close();
}

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧