CommandText.Format("UPDATE data SET siftnum = %d WHERE number = '%s'",\
      siftCount+1, m_sNum);
try
   {
    m_pRecordset = theApp.m_pConnection->Execute(_bstr_t(CommandText),&RecordsAffected,adCmdText);
   }
   catch (_com_error *e) 
   {
    AfxMessageBox(e->ErrorMessage());
   }
 
数据库为access
data 表结构
number     文本
siftnum     整型
prefix        文本
weight        双精度
persugar    双精度
sugar        双精度跟踪:执行以上代码时没问题,但在退出程序 报提示下面的错误:
abnormal program termination!
如果把m_pRecordset = theApp.m_pConnection->Execute(_bstr_t(CommandText),&RecordsAffected,adCmdText);这条语句去掉,退出正常,没问题!为什么?我的语句有写错吗?

解决方案 »

  1.   

    theApp.m_pConnection->Execute(_bstr_t(CommandText),NULL,adCmdText);
    CommandText.Format("UPDATE [data] SET siftnum = %d WHERE number = '%s'",\
          siftCount+1, m_sNum);
      

  2.   

    CommandText.Format("UPDATE [data] SET [siftnum] = %d WHERE [number] = '%s'",\
          siftCount+1, m_sNum);
      

  3.   

    为什么要加“[]”?
    我前面其他地方 update的没有用中括号都可以
      

  4.   

    theApp.m_pConnection是否已经成功连接数据库?
      

  5.   

    如果我把这句话去掉就没问题!
    theApp.m_pConnection已经成功连接数据库,因为我其他地方也有执行sql语句的
      

  6.   

    m_pRecordset = theApp.m_pConnection->Execute(_bstr_t(CommandText),&RecordsAffected,adCmdText);update查询不返回结果集,你可以把m_pRecordset去掉是一下
    theApp.m_pConnection->Execute(_bstr_t(CommandText),&RecordsAffected,adCmdText);
      

  7.   

    thxvieri_ch(尘雨-自在飞花轻似梦,无边丝雨细如愁)