Sub enter_click(ByVal sender As Object, ByVal e As EventArgs)
Dim conn As New SqlConnection("server=localhost;database=education;uid=sa;pwd=")
Dim strsqlc As String
strsqlc = "select * from login where userid='" & userid.Text & "'"
Dim cmd As New SqlCommand(strsqlc, conn)
conn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
If dr.Read() Then
message.Text = "帐号已经被注册过"
Exit Sub
Else
Dim strsql As String
strsql = "insert into login(userid,password,sex,birthday,email,telephone,name) values ('" & userid.Text & "','" & password.Text & "','" & sex.SelectedItem.Text & "','" & birthday.Text & "','" & email.Text & "','" & telephone.Text & "','" & name.Text & "')"
Dim cmdr As New SqlCommand(strsql, conn)
'Try
cmdr.ExecuteNonQuery()
conn.Close()
Response.Redirect("index.aspx")
'Catch ex As Exception
''message.Text = "没有注册成功"
'End Try
End If
End Sub
|