登入.vb 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  5. End Sub
  6. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  7. 註冊.Show()
  8. End Sub
  9. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  10. conn.Open()
  11. Dim strSQL = " SELECT * FROM [會員] WHERE 帳號 = '" & TextBox1.Text & "' And 密碼 = '" & TextBox2.Text & "'"
  12. Dim cmd = New SqlCommand(strSQL, conn)
  13. cmd.ExecuteNonQuery()
  14. Dim dr As SqlDataReader = cmd.ExecuteReader
  15. dr.Read()
  16. Try
  17. If dr(0) = 0 Then
  18. MsgBox("帳號或密碼錯誤")
  19. conn.Close()
  20. Else
  21. 耳環.Show()
  22. conn.Close()
  23. End If
  24. Catch ex As Exception
  25. MsgBox("帳號或密碼錯誤")
  26. conn.Close()
  27. End Try
  28. End Sub
  29. Private Sub Label4_DoubleClick(sender As Object, e As EventArgs) Handles Label4.DoubleClick
  30. 管理者登入.Show()
  31. End Sub
  32. End Class