9 个解决方案
#1
用COleDateTime应该没问题吧
#2
直接用字符串啊, str.Format("insert into a(thedate) values ('%s')" ,strDate);
strDate是格式好的字符串如:2000-10-10 00:00:00
strDate是格式好的字符串如:2000-10-10 00:00:00
#3
从datetime去数据到CString才需要用COleDateTime转换呢
#4
直接将CString 格式化为字符串就能插入过去么??我试试先
#5
zcp126()能再说明白点吗,我也想知道
#6
//从sql server取datetime.....>CString
variant vdate;
vdate.vt = VT_DATE;
CString strDate;
vdate = rs->GetCollect("coldate");
if ( vcate.vt != NULL)//从datetime ---> CString
strDate = COleDateTime(vdate).Format("%Y-%m-%d %H:%M:%S");
//Insert a record with datetimecolumn to sqlserver
CString sql ,strDate;
strDate = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
sql.Format("insert into A(thedate) values ('%s')" ,strDate);//构造语句
con->Execute(_bstr_t(sql),&RecordsAffected,adCmdText);//执行
variant vdate;
vdate.vt = VT_DATE;
CString strDate;
vdate = rs->GetCollect("coldate");
if ( vcate.vt != NULL)//从datetime ---> CString
strDate = COleDateTime(vdate).Format("%Y-%m-%d %H:%M:%S");
//Insert a record with datetimecolumn to sqlserver
CString sql ,strDate;
strDate = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
sql.Format("insert into A(thedate) values ('%s')" ,strDate);//构造语句
con->Execute(_bstr_t(sql),&RecordsAffected,adCmdText);//执行
#7
只要时间字符窜格式对,直接插入数据库中就可以了
#8
当字符窜那样插就可以了
#9
谢谢了zcp126()
#1
用COleDateTime应该没问题吧
#2
直接用字符串啊, str.Format("insert into a(thedate) values ('%s')" ,strDate);
strDate是格式好的字符串如:2000-10-10 00:00:00
strDate是格式好的字符串如:2000-10-10 00:00:00
#3
从datetime去数据到CString才需要用COleDateTime转换呢
#4
直接将CString 格式化为字符串就能插入过去么??我试试先
#5
zcp126()能再说明白点吗,我也想知道
#6
//从sql server取datetime.....>CString
variant vdate;
vdate.vt = VT_DATE;
CString strDate;
vdate = rs->GetCollect("coldate");
if ( vcate.vt != NULL)//从datetime ---> CString
strDate = COleDateTime(vdate).Format("%Y-%m-%d %H:%M:%S");
//Insert a record with datetimecolumn to sqlserver
CString sql ,strDate;
strDate = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
sql.Format("insert into A(thedate) values ('%s')" ,strDate);//构造语句
con->Execute(_bstr_t(sql),&RecordsAffected,adCmdText);//执行
variant vdate;
vdate.vt = VT_DATE;
CString strDate;
vdate = rs->GetCollect("coldate");
if ( vcate.vt != NULL)//从datetime ---> CString
strDate = COleDateTime(vdate).Format("%Y-%m-%d %H:%M:%S");
//Insert a record with datetimecolumn to sqlserver
CString sql ,strDate;
strDate = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
sql.Format("insert into A(thedate) values ('%s')" ,strDate);//构造语句
con->Execute(_bstr_t(sql),&RecordsAffected,adCmdText);//执行
#7
只要时间字符窜格式对,直接插入数据库中就可以了
#8
当字符窜那样插就可以了
#9
谢谢了zcp126()