|
代码如下: <% set conn=server.createobject("adodb.connection") conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("hydrology.mdb") exec="select * from st_river_r where ymdhm=" & date() set rs=server.createobject("adodb.recordset") rs.open exec,conn,1,1 %> <html> <head> <title>水位流量</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body bgcolor="#FFFFFF" text="#000000"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <% do while not rs.eof %><tr> <td><%=rs("zr")%></td> <td><%=rs("q")%></td></tr> <% rs.movenext loop %> </table> </body> </html> |
|
|
|
试试 exec="select * from st_river_r where day(ymdhm)=day(getdate())" 但这样在以后回重复的,还要加上year(xxx)=year(getdate()),month.....年月日 |
|
|
access数据库
tdate=date() exec="select * from st_river_r where ymdhm=#"&tdate&"#" |
|
|
如果是sql就要多加两个引号
至于是单引号还是双引号我忘了 |
|
|
写错了是sql server数据库
|
|
|
二楼还是不行呀!提示:ODBC驱动程序不支持所需的属性
三楼的语法有错 |
|
|
三楼的语法错误可能是tdate没定义
|
|
|
不好意思没注意到你写的是ACCESS,我用的是SQL所以通过了!
|
|
|
<%
set conn=server.createobject("adodb.connection") conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("hydrology.mdb") '你的日期格式是2004-8-11 这样的格式. exec="select * from st_river_r where ymdhm like date()" set rs=server.createobject("adodb.recordset") rs.open exec,conn,1,1 %> <html> <head> <title>水位流量</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body bgcolor="#FFFFFF" text="#000000"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <% do while not rs.eof %><tr> <td><%=rs("zr")%></td> <td><%=rs("q")%></td></tr> <% rs.movenext loop %> </table> </body> </html> |
|
|
aaa=day(now)
exec="select * from st_river_r where day(ymdhm)='"&aaa&"'" 这样可以吧! |
|
|
可以了,不过我写的是
exec="select * from st_river_r where day(ymdhm)=day(date()) and month(ymdhm)=month(date())" 因为日期要安全相同 我刚学asp,所以碰到很多问题,谢谢帮忙 马上给分啦! |
|
|
不过我搞不懂我原来的语法为什么不行?
|
|
|
|
|
|
mark
|
|