读书人

SQL数据查询有关问题

发布时间: 2012-02-01 16:58:19 作者: rapoo

SQL数据查询问题
有如下SQL语句, 在ACCESS中可以查询,但是在SQL数据库中不行,请大家帮忙。
COleDateTime starttime;
COleDateTime endtime;
CString mintm,maxtm;
mintm.Format( "%04d-%02d-%02d %02d:%02d:%02d ",starttime.GetYear(),starttime.GetMounth(),starttime.GetDay(),starttime.GetHour(),starttime.GetMinute(),starttime.GetSecond());
maxtm.Format( "%04d-%02d-%02d %02d:%02d:%02d ",endtime.GetYear(),endtime.GetMounth(),endtime.GetDay(),endtime.GetHour(),endtime.GetMinute(),endtime.GetSecond());
sql= "select * from table1 where Time between # "+mintm+ "# and # "+maxtm+ "# ";



[解决办法]
在sql server中就去掉#
[解决办法]
#改为 '或者\ "
[解决办法]
sql= "select * from table1 where Time between ' "+mintm+ " ' and ' "+maxtm+ " ' ";
[解决办法]
access 中时间用#括起来

sql server 中用 '括起来

象在相互说的那样

读书人网 >VC/MFC

热点推荐