最近用到ADO和ACCESS,发现其中的日期/时间型数据操作起来比较麻烦,反复尝试最后终于成功了,现在记录在博。
CString strSQL;
日期查询
CString m_strData;
CString strDataFormat = _T("%Y-%m-%d");
m_strData = m_dataQuery.Format(strDataFormat);//COleDataTime m_dataQuery;
strSQL = "SELECT * FROM Table WHERE Data = #"+m_strData+"#";
名称+日期 组合查询
strSQL = "SELECT * FROM Table WHERE Name like '%" + m_strName + "%' and Data = #"+m_strData+"#";
更新
strSQL = "UPDATE Table SET Name = '" + m_strName + "' WHERE ID = " + strID;
删除
strSQL = "DELETE FROM Table WHERE Value = " + strID;