?? 刪除用戶.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("請輸正確用戶名!", "系統(tǒng)信息!", 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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -