关于数据库更新字段的问题!
现在是用户登录时能看到自己上一次的登录时间(即获取登录时的时间去更新数据库的时间字段)代码如下:
报错为:ADODB.Recordset 错误 '800a0bb9 ' 参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
报错行为:sql2= "update admin set log_time=# "&date& "# where admin= ' "&admin& " ' "
<%
admin=trim(request( "admin1 "))
admin=replace(admin, " ' ", " ")
psw=trim(request( "psw "))
psw=replace(psw, " ' ", " ")
if admin= " " or psw= " " then
response.write " <script language=JavaScript> alert( '管理员名和密码不能为空! '); "
response.write "javascript:history.go(-1) </script> "
response.end
end if
set rs=server.createobject( "adodb.recordset ")
Call SQLConn
sql2= "update admin set log_time=# "&date& "# where admin= ' "&admin& " ' "
rs.open sql,conn,1,3
'rs.update
rs.close
Call SQLConn '连接数据库
sql= "select * from admin where admin = ' "&admin& " ' "
rs.open sql,conn,1,1
if not rs.eof then
if admin=rs( "admin ") and psw=rs( "password ") Then
Session( "admin ")=rs( "admin ")
Session( "password ")=rs( "password ")
Session( "type ")=rs( "type ")
Session( "id ")=rs( "id ")
Session( "log_time ")=rs( "log_time ")
rs.close
set rs=nothing
conn.close
set conn=Nothing
response.Redirect "homepage.asp "
rs.close
else
response.write " <SCRIPT language=JavaScript> alert( '密码错误,请重新输入! '); "
response.write "javascript:history.go(-1) </SCRIPT> "
End if
end if
%>
------解决方案--------------------建议先
response.write sql2
response.end
看看具体有什么问题。
------解决方案--------------------更新登录时间的这句:rs.open sql,conn,1,3
改成
conn.execute sqlquery
,conn是你自己定义的连接名
------解决方案--------------------sql2= "update admin set log_time=# "&date& "# where admin= ' "&admin& " ' "
修改成
sql2= "update admin set log_time= "&date& " where admin= ' "&admin& " ' "
------解决方案--------------------log_time是什么类型的?
你的date又是哪来的?
sql2= "update admin set log_time= "&now()& " where admin= ' "&admin& " ' "
------解决方案--------------------