镶树脂牙多少钱一颗:关于select查询,急!
来源:百度文库 编辑:中科新闻网 时间:2024/06/04 05:38:55
有一个表a
a中有一个字段time定义的是自动返回当前系统时间,返回的时间格式为:2006-5-15 即用函数date()返回的时间。
下面的语句报错:
<!--#include file="sysinc.asp"-->
<%
today=response.write(date())
sql="select *from a where time="&today
my_rs.open sql,my_conn
%>
其中的包含文件sysinc.asp是数据库连接,记录集定义,没有错误。
我想做的是返回当日time字段里面的信息,如果有别的方法也行?
我刚才改正了个错误:
将<%today=response.write(date())%>
该成了
<%today=date()%>
而且选择语句改成了:
sql="select *from a where time='"&today&"'"
提示错误原因为:
标准表达式中数据类型不匹配
a中有一个字段time定义的是自动返回当前系统时间,返回的时间格式为:2006-5-15 即用函数date()返回的时间。
下面的语句报错:
<!--#include file="sysinc.asp"-->
<%
today=response.write(date())
sql="select *from a where time="&today
my_rs.open sql,my_conn
%>
其中的包含文件sysinc.asp是数据库连接,记录集定义,没有错误。
我想做的是返回当日time字段里面的信息,如果有别的方法也行?
我刚才改正了个错误:
将<%today=response.write(date())%>
该成了
<%today=date()%>
而且选择语句改成了:
sql="select *from a where time='"&today&"'"
提示错误原因为:
标准表达式中数据类型不匹配
把代码该成下面的这个
sql="select *from a where time='"&today&"'"
如果是取当前时间 可以直接用 date()
还可以在数据库里设置字段的默认值getdata()
在SQL数据库 里面时间类型好象是被当作字符串类型处理
<%
today=response.write(date())
sql="select *from a where time='"&today&"'"
my_rs.open sql,my_conn
%>
这句语法有问题:
today=response.write(date())
实际执行后today没有被赋值。
应该用today=date()
如果你还要输出的话,可以分成两个语句来进行:
today=date()
response.write(today)
如果你使用的是access数据库,把语句改成:
sql="select * from a where time=#"&today&"#"
另外,你的time字段是什么属性的?
sql="select *from a where time='"&today&"'"
应该没有错误