asp查询时出现奇怪的问题.

来源:百度知道 编辑:UC知道 时间:2024/06/03 16:08:21
tt=request.QueryString("tt")
exec="select * from test where tt="tt" and ff='"&ff&"'"
注:tt为时间类型
我查询的时候..比如 传递过来是tt=2008-4-19,ff=111..本来应该只显示2008-4-19和符合ff=111这个条件的数据.但我这个确把所有符合ff=111这个条件不管是不是2008-4-19的都显示出来了.汗死..不知啥回事..高手帮忙下.!!~谢谢..

晕。。我来告诉你
exec="select * from test where tt="tt" and ff='"&ff&"'"

exec="select * from test where tt="&tt&" and ff='"&ff&"'"

就可以了

exec="select * from test where tt="tt" and ff='"&ff&"'"
tt是日期,在access数据库里要加上#

exec="select * from test where tt=#"&tt&"# and ff='"&ff&"'"

最好在查询时先把[tt]转成短日期格式 date(tt)=#"&tt&"#

tt=request.QueryString("tt")
exec="select * from test where tt="tt" and ff='"&ff&"'"

改为:
tt=request.QueryString("tt")
exec="select * from test where tt='"&tt&"' and ff='"&ff&"'"

'在查询语句里表示时间的只需用''就可以了