설명 없음
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

個人帳號管理.vb 1.7KB

123456789101112131415161718192021222324252627282930313233343536
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Public Class 個人帳號管理
  4. Dim conn As New SqlConnection
  5. Dim da As New SqlDataAdapter
  6. Dim cmd As New SqlCommand
  7. Dim ds As New DataSet
  8. Dim dr As SqlDataReader
  9. Private Sub Set_使用者資料()
  10. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  11. SQL1 = "SELECT 姓名, 帳號, 密碼 FROM 使用者權限管理表 WHERE (姓名 = '" & gUserName & "')"
  12. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  13. If dr.Read() Then
  14. TextBox1.Text = dr("姓名").ToString
  15. TextBox2.Text = dr("帳號").ToString
  16. TextBox3.Text = dr("密碼").ToString
  17. End If
  18. conn.Close() : dr.Close()
  19. End Sub
  20. Private Sub 個人帳號管理_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  21. FormBorderStyle = FormBorderStyle.SizableToolWindow
  22. Set_使用者資料()
  23. TextBox1.Enabled = False : TextBox2.Enabled = False
  24. End Sub
  25. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  26. If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
  27. MsgBox("輸入資料有誤")
  28. Else
  29. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  30. SQL1 = "UPDATE 使用者權限管理表 SET 帳號 = '" & TextBox2.Text & "', 密碼 = '" & TextBox3.Text & "' WHERE (姓名 = '" & TextBox1.Text & "')"
  31. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() : conn.Close()
  32. MsgBox("修改完成")
  33. End If
  34. Set_使用者資料()
  35. End Sub
  36. End Class