MFC用 ADO连接数据库,get_RecordCount总是返回-1解决办法
2012-10-05 12:09
447 查看
1.将数据库连接属性设置一下就行了,如你的连接指针变量是m_pConnection,可以这样:
::CoInitialize(NULL);
m_pConnection.CreateInstance(_uuidof(Connection)); //初始化Connection指针
m_pConnection->CursorLocation = adUseClient;
。。。。
。。。。
2.遍历数据
long n = 0;
while(!myRecordset-> adoEOF)
{
n++;
myRecordset-> MoveNext();
}
3.通过Sql语句
Select Count(*)
from 表
where 条件
m_pPtr = m_paConnection->Execute((_bstr_t)strSQL, NULL, adCmdText);
_variant_t vIndex = (long)0;
_variant_t vCount =m_pPtr->GetCollect(vIndex);
long nNum = vCount.ulVal;
::CoInitialize(NULL);
m_pConnection.CreateInstance(_uuidof(Connection)); //初始化Connection指针
m_pConnection->CursorLocation = adUseClient;
。。。。
。。。。
2.遍历数据
long n = 0;
while(!myRecordset-> adoEOF)
{
n++;
myRecordset-> MoveNext();
}
3.通过Sql语句
Select Count(*)
from 表
where 条件
m_pPtr = m_paConnection->Execute((_bstr_t)strSQL, NULL, adCmdText);
_variant_t vIndex = (long)0;
_variant_t vCount =m_pPtr->GetCollect(vIndex);
long nNum = vCount.ulVal;
相关文章推荐
- 利用ADO连接数据库时,Rs.recordcount总是返回-1,解决办法
- 查询返回的recordcount=-1的解决办法
- c++ ado方式连接11g数据库解决办法
- 关于ADO记录集GetRecordCount()返回记录条数-1的问题
- 刚安装的sql server 2008,总是连接不到数据库引擎解决办法
- 查询返回的recordcount=-1的解决办法
- 查询返回的recordcount=-1的解决办法
- 如何解决取ADO的Recordset对象的RecordCount属性总是-1
- vs2010连接数据库,函数SQLConnect中返回-1的解决办法
- MyBatis数据库连接出现Communications link failure现象的解决办法(dbcp2连接池)
- MFC使用ADO连接数据库的问题:error C2059: 语法错误 : “<L_TYPE_raw>”
- myeclipse中建立oracle数据库连接时出现ora-12705错误的解决办法
- 【MyBatis】关于MyBatis插入自动增长id的Bean到数据库后返回的id为null的解决办法
- DBNMPNTW]Connectionopen(CreateFile()) DELPHI开发的ADO应用程序连接SQL SERVER失败的解决办法
- Xutils的get请求后,总是返回同样数据的问题解决方式
- ORACLE自动断开数据库连接解决办法
- PHP数据库连接失败--could not find driver 解决办法 .
- 使用jdbc连接数据库出现“到主机的TCP/ip连接失败”的解决办法
- MFC对话框以ADO的方式连接(ACESS)数据库
- MFC ado连接数据库