.net教程:一个简单的用户登陆程序……
content-type: text/plain; charset="gb2312"
content-transfer-encoding: 8bit
以下程序是用来验证用户登录的共有两个按钮,一个是用来提交的,一个是用来重填的,页面部分就很简单了,两个文本框,两个按钮,这里页面的代码就不写了:)
private sub button2_click(byval sender as system.object, byval e as system.eventargs) handles button2.click
if textbox3.text = "" or textbox4.text = "" then
label35.text = "请确认您的输入!"
return
end if
dim sql as string = "select * from pwd where stu_id=@stu_id and pwd=@pwd"
dim comm as sqlcommand = new sqlcommand(sql, conn)
comm.parameters.add(new sqlparameter("@stu_id", sqldbtype.int, 4))
comm.parameters("@stu_id").value = textbox3.text
comm.parameters.add(new sqlparameter("@pwd", sqldbtype.char, 16))
comm.parameters("@pwd").value = textbox4.text
dim dr as sqldatareader
conn.open()
dr = comm.executereader
if dr.read then
session("stu_id") = textbox3.text
dr.close()
comm.cancel()
dim sql_3 as string = "update stu_base set point=point+1 where stu_id=@stu_id"
comm = new sqlcommand(sql_3, conn)
comm.parameters.add(new sqlparameter("@stu_id", sqldbtype.int, 4))
comm.parameters("@stu_id").value = session("stu_id")
comm.executenonquery()
comm.cancel()
response.redirect("detail.aspx?stu_id='" & session("stu_id") & "'")
else
label35.text = "您还没有注册或账号密码错误"
end if
end sub
private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click
textbox1.text = ""
textbox2.text = ""
end sub