Sub enter_click1(ByVal sender As Object, ByVal e As EventArgs) Dim strsql1 As String strsql1 = "select * from login where u_id='" & u_id.Text & "'" Dim cmd As New SqlCommand(strsql1, conn) conn.Open() Dim dr As SqlDataReader = cmd.ExecuteReader() If dr.Read Then message.Text = "对不起,您输入的用户名已经被他人使用,请选择其他名字后再试" End If End Sub Sub enter_click(ByVal sender As Object, ByVal e As EventArgs) Dim strsql2 As String strsql2 = "insert into login(u_id,u_password,u_email,u_question,u_answer,u_sex,u_qq,u_time) values ('" & u_id.Text & "','" & u_password.Text & "','" & u_email.Text & "'," & CInt(u_question.SelectedItem.Value) & ",'" & u_answer.Text & "'," & CInt(u_sex.SelectedItem.Value) & ",'" & u_qq.Text & "','" & Now() & "')" Dim cmd2 As New SqlCommand(strsql2, conn) Try cmd2.ExecuteNonQuery() conn.Close() Response.Redirect("login.aspx") Catch ex As Exception message.Text = "没有注册成功" End Try End Sub