📄 删除用户.vb
字号:
Public Class 删除用户
Inherits System.Windows.Forms.Form
Dim strconn As String = "data source=.;initial catalog=weboy;user id=sa;password=;"
Dim objds As New Data.DataSet
Dim objda As SqlClient.SqlDataAdapter
Dim bingpage As BindingManagerBase
Dim cn As New SqlClient.SqlConnection
Dim cmd As SqlClient.SqlCommand
Dim objcommand As SqlClient.SqlCommand
Dim objdr As SqlClient.SqlDataReader
Dim str1 As String
Dim strsql As String
Private Sub 删除用户_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If MaskedTextBox1.Text = "" Then
MessageBox.Show("请输入用户名称!")
Exit Sub
End If
strconn = "data source=.;initial catalog=weboy;user id=sa;password=;"
strsql = "select name,password,power from users "
objcommand = New SqlClient.SqlCommand(strsql, New SqlClient.SqlConnection(strconn))
objcommand.Connection.Open()
objdr = objcommand.ExecuteReader(CommandBehavior.CloseConnection)
With objdr
Do While .Read = True
str1 = .GetString(0)
If Trim(MaskedTextBox1.Text) = Trim(str1) Then
Dim sql As String
sql = "delete from users where name ='" & Trim(MaskedTextBox1.Text) & "'"
cn.ConnectionString = strconn
cn.Open()
cmd = New SqlClient.SqlCommand(sql, cn)
cmd.ExecuteNonQuery()
cmd.Dispose()
cn.Dispose()
MessageBox.Show("删除成功!", "恭喜!", MessageBoxButtons.OK, MessageBoxIcon.Information)
MaskedTextBox1.Text = ""
Exit Sub
Else
MessageBox.Show("请输正确用户名!", "系统信息!", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Loop
End With
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -