新手求助 用ado怎么把COleDateTime类型时间插入access? 在线等 注:access里的时间字段数据类型是 日期/时间 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 叹!,别用ACCESS了,小数据库多的是。 转换成string类型后可以写入到access,假定你的COleDateTime对应的控件变量为:m_DtCtrlCTime 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 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);我这样写错在哪呢? 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 比较推荐发帖,这样大家可以知识分享,如果没有可用分,也可以给俺发email:[email protected] 怎样在单文档中使用CButtonST? 实现类似队列的操作 MFC List Box多行显示 picture控件中显示图片,如何才能让他有透明的效果?请高人指点 如何使用installshield打包驱动程序 msxml3.dll (0x80070005)拒绝访问postnew.asp, 第 36 行 在线等 如何设置字段的格式、标题等属性 有关include之后得问题 在VC中如何显示tif图片。 前辈们:现在学com 编程,是不是晚了,若是还有别的路吗? vc7转vc6碰到的问题 关于opencv的视频流关闭异常
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
_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);
我这样写错在哪呢?
->
ss([theme], [time])
datetime字段能否接收"yyyy/mm/dd"格式俺没确认过,"yyyy-mm-dd"是可以的;
m_theme是什么格式?确认与表格字段格式匹配;
2,
e.ErrorMessage()换成:
e.Description()较好,因为后者的描述更清晰
3,UpdateData(false):更新控件数据时才需要
4,不知道你的rA是干嘛的,这里可以设置为NULL