大家帮我看下这个代码有什么问题,为什么老是找不到那个table啊
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <stdlib.h>
using std::cout;
using std::endl;
int main()
{
::CoInitialize(NULL);
HRESULT hr = NULL;
_ConnectionPtr pConnection = NULL;
hr = pConnection.CreateInstance(_uuidof(Connection));
if (FAILED(hr))
{
return 0;
}
//_bstr_t strConn = "Driver={PostgreSQL ANSI};server='192.168.1.61';uid=postgres;pwd=123456;database=DM";
_bstr_t strConn = "Provider=MSDASQL.1;Password=123456; Persist Security Info=False;User ID=postgres;Data Source=DM; Server=192.168.1.61";
try
{
pConnection->Open(strConn,"","",NULL);
}
catch (_com_error e)
{
cout << "Error:" << e.Description() << endl;
}
_RecordsetPtr pRecordset;
if (FAILED(pRecordset.CreateInstance(_uuidof(Recordset))))
{
return 0;
}
try
{
pRecordset->Open(_variant_t("tbl_devices"),_variant_t((IDispatch *)pConnection),adOpenKeyset,adLockOptimistic,adCmdTable);
}
catch (_com_error e)
{
cout << "Error:" << e.Description() << endl;
}
_bstr_t strsql = "select * from tbl_devs where use_id='1'";
pRecordset = pConnection->Execute(_bstr_t(strsql),NULL,adCmdText);
while (!pRecordset->adoEOF)
{
cout << "aa" << endl;
}
return 0;
}
高手帮忙看一下啊
[解决办法]
问题说清楚些
[解决办法]
楼主把问题说清楚呢。或者自己加断点调试吧