在线等 注:access里的时间字段数据类型是 日期/时间

解决方案 »

  1.   

    叹!,别用ACCESS了,小数据库多的是。
      

  2.   

    转换成string类型后可以写入到access,假定你的COleDateTime对应的控件变量为:m_DtCtrl
    CTime vTime;
    m_DtCtrl.GetTime(vTime);//从控件m_DtCtrl读入到vTime中
    CString strDate=vTime.Format("%Y-%m-%d");//yyyy-mm-dd模式
    CString strDate=vTime.Format("%Y-%m-%d %H:%M:%S");//yyyy-mm-dd hh:mm:ss模式最后将strDate写入到access
      

  3.   

    CString sql;
    _variant_t rA;
    CString strtime;
    strtime=m_time.Format("%Y/%m/%d");
    UpdateData(true);
    sql.Format("insert into ss(theme, time) values('%s','%s')", m_theme,strtime);
    _bstr_t bstrInsert=sql;
    try
    { AfxMessageBox(m_time.Format( "%Y/%m/%d   %H:%M:%S "));
    m_pConnection->Execute(bstrInsert,&rA,adCmdText);
    AfxMessageBox("插入成功!");
    }
    catch(_com_error e)
    { CString errormessage;
    errormessage.Format("错误%s", e.ErrorMessage());
    AfxMessageBox(errormessage);
    return;
    }
    UpdateData(false);
    我这样写错在哪呢?
      

  4.   

    1,ss(theme, time)
    ->
    ss([theme], [time])
    datetime字段能否接收"yyyy/mm/dd"格式俺没确认过,"yyyy-mm-dd"是可以的;
    m_theme是什么格式?确认与表格字段格式匹配;
    2,
    e.ErrorMessage()换成:
    e.Description()较好,因为后者的描述更清晰
    3,UpdateData(false):更新控件数据时才需要
    4,不知道你的rA是干嘛的,这里可以设置为NULL
      

  5.   

    比较推荐发帖,这样大家可以知识分享,如果没有可用分,也可以给俺发email:[email protected]