CString sSql = "";
CTime tTime = CTime::GetCurrentTime();
CString m_sLoginTime = tTime.Format("%Y-%m-%d %H:%M:%S"); sSql.Format("INSERT INTO [tb_tc_info]([tc_ltime])VALUES('%s')",m_sLoginTime); if (!g_dhDatabaseHelper.Execute(sSql, NULL, NULL))
{
AfxMessageBox("插入数据库失败");
}

解决方案 »

  1.   

    1. 把生成的sSql语句拷出来在数据库下执行一下看看结果2. 加上try catch异常处理,查看异常信息
      

  2.   

    tc_ltime 如果是时间类型的话,插入不能直接插入字符串,必须转换下
    2010-1-1转换为#2010-1-1#
      

  3.   

    可能是字段的数据类型不匹配.改这样试下.sSql.Format("INSERT INTO [tb_tc_info]([tc_ltime])VALUES(convert(datetime,'%s'))",m_sLoginTime);
      

  4.   

    加异常捕获看是什么错误,估计是其他有的字段也需要值。
    try
    {
    //你的ADO代码
    }
    catch (_com_error& e)
    {
    AfxMessageBox(e.Description());
    }