当前位置: 代码迷 >> VC >> 持续:vs2005 vc access 取不到表中的数据
  详细解决方案

持续:vs2005 vc access 取不到表中的数据

热度:11071   发布时间:2013-02-25 00:00:00.0
继续:vs2005 vc access 取不到表中的数据
我有如下一段代码:
CString str,strSql;
str.Format(_T(林));
strSql.Format(_T("SELECT * FROM Mytable WHERE Trim(sz)='")+str+"'");

m_pRecordset.createInstance(__uuidof(Recordset));

try{
  m_pRecordset->Open((_varient_t)strSql,theApp.m_pConnect.GetInterfacePtr(),
  adOpenStatic,adLockOptimistic,adCmdText);
}
catch(_com_error_ e){
  AfxMessageBox(e...);
}

try{
  if (!m_pRecordset->adoBOF)
  m_pRecordset->MoveFirst();
  else
  AfxMessageBox(_T("没有找到符合条件的记录"));
......
......
程序运行结果显示:没有找到符合条件的记录。

问题是我的Access表Mytable确实有一条记录,其字段sz的值是“林”,为什么记录集返回为空,找不到呢?

ps:我用access2003,表格中字段sz的类型是text,整个表格没有建立主索引。

哪个高手告诉一下原因,我去结贴,嘿嘿。。

------解决方案--------------------------------------------------------
这种情况几乎不可能。你考虑一下,是不是你的记录加删除标记了。删除的记录用select 是看不出来的,所以movenext跳了几行。。。
  相关解决方案