如果数据库(表)是空的,并且有一个字段是时间类型(VC中对应CTime)的话,
添加记录就会出问题?奇怪,(用snapshot)
还有怎么我用dynaset老告诉我不支持?
thx

解决方案 »

  1.   

    在AddNew以前加上下面的函数试试
    pSet->SetFieldNull(NULL);CRecordset::SetFieldNull
    void SetFieldNull( void* pv, BOOL bNull = TRUE );ParameterspvContains the address of a field data member in the recordset or NULL. If NULL, all field data members in the recordset are flagged. (C++ NULL is not the same as Null in database terminology, which means “having no value.”)bNullNonzero if the field data member is to be flagged as having no value (Null). Otherwise 0 if the field data member is to be flagged as non-Null.ResCall this member function to flag a field data member of the recordset as Null (specifically having no value) or as non-Null. When you add a new record to a recordset, all field data members are initially set to a Null value and flagged as “dirty” (changed). When you retrieve a record from a data source, its columns either already have values or are Null.Note   Do not call this member function on recordsets that are using bulk row fetching. If you have implemented bulk row fetching, calling SetFieldNull results in a failed assertion. For more information about bulk row fetching, see the articleRecordset: Fetching Records in Bulk (ODBC) in Visual C++ Programmer’s Guide.If you specifically wish to designate a field of the current record as not having a value, call SetFieldNull with bNull set to TRUE to flag it as Null. If a field was previously ed Null and you now want to give it a value, simply set its new value. You do not have to remove the Null flag with SetFieldNull. To determine whether the field is allowed to be Null, call IsFieldNullable. Important   Call this member function only after you have called Edit or AddNew.Using NULL for the first argument of the function will apply the function only to outputColumns, not params. For instance, the callSetFieldNull( NULL );will set only outputColumns to NULL. Params will be unaffected.To work on params, you must supply the actual address of the individual param you want to work on, such as:SetFieldNull( &m_strParam );This means you cannot set all params NULL, as you can with outputColumns.Note   When setting parameters to Null, a call to SetFieldNull before the recordset is opened results in an assertion. In this case, call SetParamNull.SetFieldNull is implemented through DoFieldExchange.CRecordset Overview |  Class Members |  Hierarchy ChartSee Also   CRecordset::IsFieldNull, CRecordset::SetFieldDirty, CRecordset::Edit, CRecordset::Update, CRecordset::IsFieldNullable
    --------------------------------------------------------------------------------
    Send
      

  2.   

    and you can also try
    CRecordset::dynamic
      

  3.   

    会不会是时间类型的问题啊?Access中的类型和SQL中的很多都不是兼容的,比较烦人!!!
      

  4.   

    to:: nuaawyd(我是菜鸟,我怕谁!) 
    果然是这个问题。
    BTW:多谢各位了。