H
hansland
Unregistered / Unconfirmed
GUEST, unregistred user!
大侠:
我用vc ado智能指针 从数据库中读取数据,可是提取数据的速度太慢,如何能不用adorecordset的 movenext() 函数,实现一次取多条记录?
代码如下:
#import "c:/Program Files/Common Files/System/ADO/msado15.dll" /
no_namespace rename("EOF", "EndOfFile")
#include <stdio.h>
// Note 1
inline void TESTHR( HRESULT _hr )
{ if FAILED(_hr) _com_issue_error(_hr);
}
typedef struct salary{
char name[20];
int salary;
};
void main(void)
{
CoInitialize(NULL);
try
{
_RecordsetPtr pRs("ADODB.Recordset");
_ConnectionPtr pCn("ADODB.Connection");
_variant_t var;
_bstr_t bstr;
vtCriteria;
long ix[1];
salary emSalary[100000]
pCn->Open("Provider=sqloledb;Data Source=192.168.10.10;"
"Initial Catalog=mydb;User Id=sa;Password=;",
strMissing, "",
adConnectUnspecified);
char sqlstr[260] = "select name,salary from t_emploayee";
pRs.open(sqlstr,
_variant_t((IDispatch *) pCn, true),
adOpenDynamic,
adLockReadOnly,
adCmdText);
int i = 0;
while(!pRs.eof)
{
var = pRs.Fields->Item["name"]->Value;
bstr = var;
strcpy(emSalary.name,(LPCSTR)bstr);
var = pRs.Fields->Item["salary"]->Value;
bstr = var;
emSalaray.salary = (int)bstr;
pRs.MoveNext();////这里处理太慢
i++;
}
catch(_com_error e)
{
/////////
}
CoUninitialize();
}
我用vc ado智能指针 从数据库中读取数据,可是提取数据的速度太慢,如何能不用adorecordset的 movenext() 函数,实现一次取多条记录?
代码如下:
#import "c:/Program Files/Common Files/System/ADO/msado15.dll" /
no_namespace rename("EOF", "EndOfFile")
#include <stdio.h>
// Note 1
inline void TESTHR( HRESULT _hr )
{ if FAILED(_hr) _com_issue_error(_hr);
}
typedef struct salary{
char name[20];
int salary;
};
void main(void)
{
CoInitialize(NULL);
try
{
_RecordsetPtr pRs("ADODB.Recordset");
_ConnectionPtr pCn("ADODB.Connection");
_variant_t var;
_bstr_t bstr;
vtCriteria;
long ix[1];
salary emSalary[100000]
pCn->Open("Provider=sqloledb;Data Source=192.168.10.10;"
"Initial Catalog=mydb;User Id=sa;Password=;",
strMissing, "",
adConnectUnspecified);
char sqlstr[260] = "select name,salary from t_emploayee";
pRs.open(sqlstr,
_variant_t((IDispatch *) pCn, true),
adOpenDynamic,
adLockReadOnly,
adCmdText);
int i = 0;
while(!pRs.eof)
{
var = pRs.Fields->Item["name"]->Value;
bstr = var;
strcpy(emSalary.name,(LPCSTR)bstr);
var = pRs.Fields->Item["salary"]->Value;
bstr = var;
emSalaray.salary = (int)bstr;
pRs.MoveNext();////这里处理太慢
i++;
}
catch(_com_error e)
{
/////////
}
CoUninitialize();
}