怎样用access创建登陆窗体,就是那种最简单的

怎样用access创建登陆窗体,就是那种最简单的,第1张

这个,首先你要会用宏,否则你就要会写VBA。

多用户登陆,你可以全用VB编写程序,也可以在access中做一个用户基本资料,把用户资料先录入进去。

逻辑就是,用宏或VBA,检测输入的账号和密码与用户表中的账户和密码的符合性。

更深入一点,那就是你得做一个表,做一个登录窗体,登录窗体就象那个QQ登录的一样,做个输入账号的text,做个输入密码的text,然后做一个确认按钮,做一个取消按钮,确认按扭中单击事件中写入程序,一按,程序就进行比较。正确就关掉登陆窗,错误就提醒一下。很简单的,相信你如此聪明,一想就明白了。

如果再不明白,请把财富值加到500,手把手的教你怎么做哈,不是我太贪,而是你太抠门了,这么复杂的工程,30个财富值怎么学得会呢,嗯,一定得再加点,太少了。

<%

response.buffer=true

issqldatabase=0'定义数据库类别,0为access数据库,1为sql数据库

if issqldatabase=0 then

'''''''''''''''''''''''''''''' access数据库 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''

datapath="" '数据库目录的相对路径

datafile="5AC.mdb" '数据库的文件名

connstr="provider=microsoft.jet.oledb.4.0data source="&server.mappath(""&datapath&""&datafile&"")

'connstr="dbq="&server.mappath(""&datapath&""&datafile&"")&"driver={microsoft access driver (*.mdb)}"

sqlnowstring="now()"

sqlchar="'"

use_conn = "yes"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

end if

on error resume next

set conn=server.createobject("adodb.connection")

conn.open connstr

if err then

err.clear

set conn = nothing

response.write "数据库链接失败,请与管理员联系。"

response.end

end if

on error goto 0

user=replace(trim(request.form("txtUserName")),"'","''")

password=replace(trim(request.form("txtPassword")),"'","''")

w_ip=Request.ServerVariables("REMOTE_ADDR")

if instr(user,"%") or instr(user,"#") or instr(user,"?") or instr(user,"|") then

response.write "<script language=javascript>alert('您的姓名含有非法字符!')this.location.href='login.asp'</script>"

response.end

end if

if instr(password,"%") or instr(password,"#") or instr(password,"?") or instr(password,"|") then

response.write "<script language=javascript>alert('您的密码含有非法字符!')this.location.href='login.asp'</script>"

response.end

end if

sql="select * from admin

where username='"&user&"' and password

='"&password&"'"

set rs=conn.execute(sql)

if rs.eof then

Response.Write("<script language=javascript>alert('您所输入的管理员姓名和密码有误!')this.location.href='login.asp'</script>")

Response.End

else

Session("w_admin")=user

Response.Write("<script language=javascript>alert('欢迎您:"&Session("w_admin")&" 登陆时间为:"&now()&"')this.location.href='index.asp'</script>")

end if

rs1.close

set rs1=nothing

conn.close

set conn=nothing

%>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8073602.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存