CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  数据库

关于使用CRecordset向oracle中存储日期类型出错。急救。

楼主robotchuan(庄聚闲)2003-09-02 20:28:02 在 VC/MFC / 数据库 提问

问题出在向、数据库中第一条存储数据时会报一个assert错,但是在其他的地方存储时就不会出错。  
  我是派生了一个CRecordset的类,在数据库中对应的值的类型是DATE类型。  
   
  下面有一些关键的代码,  
  变量定义  
  CTime   m_Pln_Date_B;  
  CTime   m_Pln_Date_E;  
  CTime   m_Fat_Date_B;  
  CTime   m_Fat_Date_E;  
   
  数据交换  
  RFX_Date(pFX,   _T("[PLN_DATE_E]"),   m_Pln_Date_E);  
  RFX_Date(pFX,   _T("[FAT_DATE_B]"),   m_Fat_Date_B);  
  RFX_Date(pFX,   _T("[FAT_DATE_E]"),   m_Fat_Date_E);  
  RFX_Date(pFX,   _T("[PLN_DATE_B]"),   m_Pln_Date_B);  
   
  在这个地方使用dbImages变量来进行数据库的存取。  
  dbImages.Open();  
  dbImages.AddNew();  
   
  dbImages.m_Pln_Date_B=   CTime(   2001,   1,   2,   3,   3,   3   );  
  dbImages.m_Pln_Date_E=   CTime(   2002,   1,   2,   3,   3,   3   );  
  dbImages.m_Fat_Date_B=   CTime(   2003,   1,   2,   3,   3,   3   );  
  dbImages.m_Fat_Date_E=   CTime(   2004,   1,   2,   3,   3,   3   );  
   
  dbImages.Update();  
  dbImages.Close(); 问题点数:100、回复次数:1Top

1 楼nonocast(如果没有如果)回复于 2003-09-03 15:59:53 得分 100

REF   MSDN  
  If   you   are   not   using   the   ODBC   cursor   library,   you   may   encounter   a   problem   when   attempting   to   update   two   or   more   long   variable-length   fields   using   the   Microsoft   SQL   Server   ODBC   driver   and   the   MFC   ODBC   database   classes.   The   ODBC   types,   SQL_LONGVARCHAR   and   SQL_LONGVARBINARY,   map   to   "text"   and   "image"   SQL   Server   types.   A   CDBException   will   be   thrown   if   you   update   two   or   more   long   variable-length   fields   on   the   same   call   to   CRecordset::Update.   Therefore,   do   not   update   multiple   long   columns   simultaneously   with   CRecordset::Update.   You   can   update   multiple   long   columns   simultaneously   with   the   ODBC   API   SQLPutData.   You   can   also   use   the   ODBC   cursor   library,   but   this   is   not   recommended   for   drivers,   like   the   SQL   Server   driver,   that   support   cursors   and   don’t   need   the   cursor   library.  
   
  If   you   are   using   the   ODBC   cursor   library   with   the   MFC   ODBC   database   classes   and   the   Microsoft   SQL   Server   ODBC   driver,   an   ASSERT   may   occur   along   with   a   CDBException   if   a   call   to   CRecordset::Update   follows   a   call   to   CRecordset::Requery.   Instead,   call   CRecordset::Close   and   CRecordset::Open   rather   than   CRecordset::Requery.   Another   solution   is   not   to   use   the   ODBC   cursor   library,   since   the   SQL   Server   and   the   SQL   Server   ODBC   driver   provide   native   support   for   cursors   natively   and   the   ODBC   cursor   library   isn’t   needed.  
   
  如果是因为这样的话,而数据又能正确入库,那其实换成release版编译应该就没有问题了。  
  Top

相关问题

  • 连接出错:LNK2005,LNK4006,急救!
  • 急救:explorer出错了~
  • oracle 急救
  • CRecordSet::GetFieldValue出错??
  • 急救Oracle数据.
  • oracle导出错误!
  • 连接oracle出错
  • 连接oracle出错?
  • Microsoft odbc for oracle 出错!
  • 连接ORACLE出错

关键词

  • date
  • 数据库
  • 数据
  • sql
  • crecordset
  • dbimages
  • pln
  • ctime
  • odbc
  • rfx

得分解答快速导航

  • 帖主:robotchuan
  • nonocast

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo