组合框获取时间问题 本帖最后由 chenwei234 于 2012-06-08 12:40:52 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CString strComBox;m_comb_year->GetWindowTextW(strComBox); 通过:Cstring m_strYY,m_strMM;int index = m_comb_year.GetCurSel();m_comb_year.GetLBText(index, m_strYY);index = m_comb_month.GetCurSel();m_comb_month.GetLBText(index, m_strMM); 已经能够获取到所选择的年,月字符串:m_strYY,m_strMM了。问题是怎么把字符串 写成 #1901-01-18# and #1901-01-23# " 这样的形似,并且代替到select语句当中不出错。 好像这是动态 sql 的问题。我做如下测试:CString cDate="1900-01-18";//查询_RecordsetPtr m_pRecordset;m_pRecordset.CreateInstance("ADODB.Recordset");m_pRecordset->Open("SELECT * FROM t57972 where ID1 between " + cDate + " and #1900-1-23# ",_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);出现如下错误:J:\CEop_tee0606\TeeTu.cpp(214) : error C2664: 'Open' : cannot convert parameter 1 from 'class CString' to 'const class _variant_t &'常量 写成#1900-1-23# 是正确的。字符串变量cDate 要如何写??我在网上看到有人这样写:CString sqlstr=_T("select [交易号] from [交易记录] where [日期] between #"+date1+"# and #"+date2+"#"); # " + cDate + " # 也出现同样的错误。是查询方式不对吗??我用的是ado 直接用Recordset对象进行查询取得记录集 方式。求教高手!!!!! 窗口拖动,如何响应LBUTTONUP消息? 请问怎么取出CString 的其中某几位 有一个小项目,有兴趣的请留下E_MAIL 怎么让隐式调用的DLL在主程序结束之前先退出线程???????? 惊世之作!VD3.0!(Visual DBTOOLS 3.0) _T()是什么意思? 大家可以简单的试一试 关于ADO的问题,很急 高分 chtmlview 刷新 缓存 问题 请问怎么样获取listview中多选的项? ODBC方式操作Sql Server问题,兄弟们,帮帮我吧! 请教大家的面试经验
m_comb_year->GetWindowTextW(strComBox);
Cstring m_strYY,m_strMM;
int index = m_comb_year.GetCurSel();
m_comb_year.GetLBText(index, m_strYY);index = m_comb_month.GetCurSel();
m_comb_month.GetLBText(index, m_strMM); 已经能够获取到所选择的年,月字符串:m_strYY,m_strMM了。问题是怎么把字符串 写成 #1901-01-18# and #1901-01-23# " 这样的形似,并且代替到select语句当中不出错。
我做如下测试:
CString cDate="1900-01-18";
//查询
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open("SELECT * FROM t57972 where ID1 between " + cDate + " and #1900-1-23# ",_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
出现如下错误:
J:\CEop_tee0606\TeeTu.cpp(214) : error C2664: 'Open' : cannot convert parameter 1 from 'class CString' to 'const class _variant_t &'
常量 写成#1900-1-23# 是正确的。
字符串变量cDate 要如何写??
我在网上看到有人这样写:
CString sqlstr=_T("select [交易号] from [交易记录] where [日期] between #"+date1+"# and #"+date2+"#"); # " + cDate + " # 也出现同样的错误。
是查询方式不对吗??我用的是ado 直接用Recordset对象进行查询取得记录集 方式。求教高手!!!!!