<script language="vb" runat="server"> sub page_load(sender as object, e as eventargs) if not page.ispostback then step1.visible = true step2.visible = false step3.visible = false end if end sub
sub button1_click(sender as object, e as eventargs) dim connstr,sqlquery as string dim i as integer = 0 connstr = "driver={sql server}; server=localhost; uid=sa; pwd=; database=mytest" sqlquery = "select vcname, vctel, vcaddr from tb_user where vcuserid = '" & userid.text & "' and vcpassword = '" & password.text & "'" dim cmd as adodatasetcommand = new adodatasetcommand(sqlquery, connstr) dim rs as dataset = new dataset() cmd.filldataset(rs, "tb_user") dim dt as datatable = rs.tables("tb_user") i = dt.rows.count if i = 1 then name.text = dt.rows(0).item(0) tel.text = dt.rows(0).item(1) addr.text = dt.rows(0).item(2) step1.visible = false step2.visible = true step3.visible = false else step1.visible = true step2.visible = false step3.visible = false div1.innerhtml = "登录失败!请检查你的帐号和密码是否正确!" end if end sub
sub button2_click(sender as object, e as eventargs) step1.visible = false step2.visible = false step3.visible = true
sub button3_click(sender as object, e as eventargs) dim connstr, sqlquery as string connstr = "driver={sql server}; server=localhost; uid=sa; pwd=; database=mytest" sqlquery = "update tb_user set vcname = '" & name.text & "', vctel = '" & tel.text & "', vcaddr = '" & addr.text & "'" dim cmd as adocommand = new adocommand(sqlquery, connstr) cmd.activeconnection.open() cmd.execute() if cmd.recordsaffected = 1 then div4.innerhtml = "你的个人资料已经被正确修改!<a href=""panelsc.aspx"">按此返回登录</a>" else div4.innerhtml = "发生错误!<a href=""javascript:history.back(-1)"">按此返回重新修改</a>" end if end sub </script>