CreatUser.aspx.vb
上传用户:bhp852
上传日期:2022-07-12
资源大小:22k
文件大小:2k
- Imports System.Data
- Imports System.Data.OleDb
- Partial Class reg
- Inherits System.Web.UI.Page
- Shared passstr As String
- Sub Next1_Click(ByVal Sender As Object, ByVal e As EventArgs) Handles Button1.Click
- Dim Cnn As OleDbConnection
- Dim Cmd As OleDbCommand
- Dim Dr As OleDbDataReader
- Dim StrSql As String
- Dim StrSql1 As String
- Dim StrCnn As String
- If (Page.IsValid) Then
- StrCnn = " Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("user.DMB.mdb") '连接字串
- StrSql1 = "select * from usersheet where LoginName ='" + TextBox1.Text.ToString + "'" '查找数据库中是否已有该用户ID
- Cnn = New OleDbConnection(StrCnn)
- Cnn.Open() '连接数据库
- Cmd = New OleDbCommand(StrSql1, Cnn)
- Dr = Cmd.ExecuteReader()
- If (Dr.Read()) Then '当数据库中已存在当前输入ID时提示重新输入
- ErrorMessage.Text = "该用户名已存在,请重新输入!"
- Cnn.Close()
- Else '当当前输入ID不存在,记录用户信息并写入数据库
- If TextBox2.Text.ToString = TextBox3.Text.ToString Then
- StrSql = "insert into UserSheet(LoginName,UserPass,UserName,Address) Values('" + TextBox1.Text.ToString + "',"
- StrSql = StrSql + "'" + TextBox2.Text.ToString + "','" + TextBox4.Text.ToString + "','" + TextBox5.Text.ToString + "')"
- Cmd = New OleDbCommand(StrSql1, Cnn)
- Dr = Cmd.ExecuteReader
- If Not (Dr.Read()) Then
- Dr.Close()
- Cmd = New OleDbCommand(StrSql, Cnn) '将数据写入数据库
- Cmd.ExecuteNonQuery()
- End If
- Panel1.Visible = False '隐藏当前panel
- Panel10.Visible = True '显示注册成功文本panel
- Cnn.Close()
- End If
- End If
- End If
- End Sub
- End Class