日期:2014-05-17 浏览次数:20581 次
<%@ import NameSpace="System.Data" %>
<%@ import NameSpace="System.Data.OLEDB" %>
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Sub aa(Sender As Object, E As EventArgs)
Session("name")=TextBox1.Text
Dim filename,filepath As String
'Path.GetFileName方法可以从任何一个路径字符串中获取文件名称
filename= Path.GetFileName(a.postedfile.filename)
'filepath是服务器端保存上传文件的物理路径
filepath= "e:\bb22\dd\" & filename
'保存上传文件
a.PostedFile.SaveAs(filepath)
message.text="<img src= "& filepath & ">"
Session("tupian")=message.text
'建立Connection对象
dim conn as new OLEDBConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("aa.mdb"))
dim conn1 as new OLEDBConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("bb.mdb"))
'建立Command对象
Dim cmd As New OLEDBCommand("insert into aa(name,spass,img1) values('"& TextBox1.text &"','"& TextBox2.text &"','"& filepath &"')",conn)
Dim cmd2 As New OLEDBCommand("insert into bb(name) values('"& TextBox1.text &"')",conn1)
'执行操作,插入记录
conn.open() '打开数据库
cmd.ExecuteNonQuery()
conn.close()
conn1.open()
cmd2.ExecuteNonQuery()
conn1.close()
Response.Redirect("tiaozhuan.aspx")
End Sub
Sub aa1(Sender As Object, E As EventArgs)
TextBox1.text=""
TextBox2.text=""
TextBox3.text=""
End Sub
Sub aa2(Sender As Object, E As EventArgs)
Response.Redirect("delu.aspx")
End Sub
</script>
<html>
<html>
<head>
<title>英雄联盟注册页面</title>
</head>
<body background="图片/881.gif">
<h4 align="center">英雄联盟注册页面</h4>
<Form Runat="Server">
<center><table><tr><td>
请输入账号:<Asp:TextBox Runat="Server" Id="TextBox1"/><br>
请输入密码:<Asp:TextBox Runat="Server" Id="TextBox2"/><br>
请确认密码:<Asp:TextBox Runat="Server" Id="TextBox3"/><<br>
<Asp:CompareValidator Runat="Server" ControlToValidate="TextBox3" display="dynamic" ControlToCompare="TextBox2" ErrorMessage="两次输入的密码必须一致!"/><br>
上传个人图片:<input id="a" type="file" runat="server">
</td></tr></table></center><br>
<center><ASP:Button Runat="Server" text="注册" Onclick="aa" /><ASP:Button Runat="Server" text="取消" Onclick="aa1" /><ASP:Button Runat="Server" text="已有账号" Onclick="aa2" /></center>