日期:2014-05-17  浏览次数:20949 次

很久没有用asp,忘了这里错在哪?

<%
dim   startime,conn,connstr,db,rs
startime=timer()
db= "dataaspzhiwang.mdb "   '数据库
on   error   resume   next   '尝试连数据库,一直到超时,但可以加强SQL注入过滤
connstr   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source= "   &   Server.MapPath(db)
'connstr= "DBQ= "+server.mappath( " "&db& " ")+ ";DefaultDir=;DRIVER={Microsoft   Access   Driver   (*.mdb)}; "
set   conn=server.createobject( "ADODB.CONNECTION ")
conn.open   connstr
bianliang=date()
set   rs=server.CreateObject( "adodb.recordset ")
        rs.open   "select   *   count   where   date= "&bianliang   ,conn,1,1
if   rs.recordcount=0   then  
rs.addnew
rs( "countnum ")=1
rs( "date ")=bianliang
rs.update
set   rs=nothing
else
countliang=rs( "countnum ")+1
today=rs( "date ")
rs.open   "update   count   set     countnum= "&countliang& "   where   date= "&today
set   rs=nothing
end   if
%>
ok!!!

------解决方案--------------------
<%
dim conn,connstr,db,rs

db= "dataaspzhiwang.mdb " '数据库
'on error resume next '尝试连数据库,一直到超时,但可以加强SQL注入过滤
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath(db)
'connstr= "DBQ= "+server.mappath( " "&db& " ")+ ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}; "
set conn=server.createobject( "ADODB.CONNECTION ")
conn.open connstr
bianliang=date

set rs=server.CreateObject( "adodb.recordset ")
rs.open "select * from [count] where [date] = # "&bianliang& "# ",conn,3,2
if rs.recordcount=0 then
rs.addnew
rs( "countnum ")=1
rs( "date ")=bianliang
rs.update
set rs=nothing
else
countliang=rs( "countnum ")+1
rs( "countnum ") = countliang
rs.update
set rs=nothing
end if
%>