为何运行之后,不管输入的用户名是什么,弹出的都是"该用户已经存在,请选另一个用户名!"
为什么运行之后,不管输入的用户名是什么,弹出的都是"该用户已经存在,请选另一个用户名!"
为什么运行之后,不管输入的用户名是什么,弹出的都是"该用户已经存在,请选另一个用户名!"[/b]
Private Sub BtAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtAdd.Click
Dim comstr As String
Dim SqlConn As New SqlClient.SqlConnection
SqlConn.ConnectionString = "Server=MS-201303151602\SQLEXPRESS;Database=信息追踪系统;"
Try
If CmbPurview.Text = "一般用户" Then
If TxtPassword.Text = TxtConfirmPassword.Text Then
comstr = "insert into " & CmbPurview.Text & " values('" & TxtUserName.Text & "','" & CChar(TxtPassword.Text) & "')"
Dim mycom As New SqlCommand(comstr, SqlConn)
SqlConn.Open()
mycom.ExecuteNonQuery()
SqlConn.Close()
MsgBox("添加成功!")
Else
MsgBox("两次密码输入不相同,请重新输入!")
TxtPassword.Text = ""
TxtConfirmPassword.Text = ""
TxtPassword.Focus()
End If
Else
If TxtPassword.Text = TxtConfirmPassword.Text And TxtSuperPassword.Text = "apple" Then
comstr = "insert into " & CmbPurview.Text & " values('" & TxtUserName.Text & "','" & CChar(TxtPassword.Text) & "')"
Dim mycom As New SqlCommand(comstr, SqlConn)
SqlConn.Open()
mycom.ExecuteNonQuery()
MsgBox("添加成功!")
Else
MsgBox("密码错误!")
TxtPassword.Text = ""
TxtConfirmPassword.Text = ""
TxtSuperPassword.Text = ""
TxtPassword.Focus()
End If
End If
Catch ex As Exception
MsgBox("该用户已经存在,请选另一个用户名!")
TxtUserName.Text = ""
TxtUserName.Focus()
Finally
SqlConn.Close()
End Try
End Sub
为什么运行之后,不管输入的用户名是什么,弹出的都是"该用户已经存在,请选另一个用户名!"
为什么运行之后,不管输入的用户名是什么,弹出的都是"该用户已经存在,请选另一个用户名!"[/b]
Private Sub BtAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtAdd.Click
Dim comstr As String
Dim SqlConn As New SqlClient.SqlConnection
SqlConn.ConnectionString = "Server=MS-201303151602\SQLEXPRESS;Database=信息追踪系统;"
Try
If CmbPurview.Text = "一般用户" Then
If TxtPassword.Text = TxtConfirmPassword.Text Then
comstr = "insert into " & CmbPurview.Text & " values('" & TxtUserName.Text & "','" & CChar(TxtPassword.Text) & "')"
Dim mycom As New SqlCommand(comstr, SqlConn)
SqlConn.Open()
mycom.ExecuteNonQuery()
SqlConn.Close()
MsgBox("添加成功!")
Else
MsgBox("两次密码输入不相同,请重新输入!")
TxtPassword.Text = ""
TxtConfirmPassword.Text = ""
TxtPassword.Focus()
End If
Else
If TxtPassword.Text = TxtConfirmPassword.Text And TxtSuperPassword.Text = "apple" Then
comstr = "insert into " & CmbPurview.Text & " values('" & TxtUserName.Text & "','" & CChar(TxtPassword.Text) & "')"
Dim mycom As New SqlCommand(comstr, SqlConn)
SqlConn.Open()
mycom.ExecuteNonQuery()
MsgBox("添加成功!")
Else
MsgBox("密码错误!")
TxtPassword.Text = ""
TxtConfirmPassword.Text = ""
TxtSuperPassword.Text = ""
TxtPassword.Focus()
End If
End If
Catch ex As Exception
MsgBox("该用户已经存在,请选另一个用户名!")
TxtUserName.Text = ""
TxtUserName.Focus()
Finally
SqlConn.Close()
End Try
End Sub
为什么运行之后,不管输入的用户名是什么,弹出的都是"该用户已经存在,请选另一个用户名!"