管理者登入.vb 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. Imports System.Data.SqlClient
  2. Public Class 管理者登入
  3. Dim conn As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\奕穎\Documents\資管\大三上\系分\謎鹿\謎鹿.mdf;Integrated Security=True;Connect Timeout=30")
  4. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  5. 登入.Show()
  6. Me.Visible = False
  7. End Sub
  8. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  9. conn.Open()
  10. Dim strSQL = " SELECT * FROM [管理者] WHERE 帳號 = '" & TextBox1.Text & "'"
  11. Dim cmd = New SqlCommand(strSQL, conn)
  12. cmd.ExecuteNonQuery()
  13. Dim dr As SqlDataReader = cmd.ExecuteReader
  14. dr.Read()
  15. Try
  16. If dr(0) = 0 Then
  17. MsgBox("帳號錯誤")
  18. conn.Close()
  19. Else
  20. 管理者介面.Show()
  21. conn.Close()
  22. End If
  23. Catch ex As Exception
  24. MsgBox("帳號錯誤")
  25. conn.Close()
  26. End Try
  27. End Sub
  28. End Class