关于使用CRecordset向oracle中存储日期类型出错。急救。
问题出在向、数据库中第一条存储数据时会报一个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




