Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. Imports MySql.Data.MySqlClient
  2.  
  3. Public Class Form1
  4. Dim conn As New MySqlConnection
  5. Private Function Connect(ByVal server As String, ByRef user As String, ByRef password As String, ByRef database As String)
  6. 'On se connecte avec les information donner
  7. conn.ConnectionString = "server=" + server + ";" _
  8. & "user id=" + user + ";" _
  9. & "password=" + password + ";" _
  10. & "database=" + database + ";"
  11. Try
  12. 'Si il y a aucune erreur on ouvre la connexion
  13. conn.Open()
  14. Return True
  15. Catch ex As MySqlException
  16. 'Si il y a une erreur on affiche le message suivant
  17. Return MsgBox("Aucune Connexion au Mysql")
  18. End Try
  19. End Function
  20. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  21. Connect("localhost", "root", "", "miniteck") 'On change si besoin
  22. End Sub
  23.  
  24. Private Sub KryptonButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton1.Click
  25. Dim myCommand As New MySqlCommand
  26. Dim myAdapter As New MySqlDataAdapter
  27. Dim myData As MySqlDataReader
  28. Dim SQL As String
  29. Dim Email As String = KryptonTextBox1.Text.Replace("'", "\'")
  30. Dim motdepasse As String = KryptonTextBox2.Text.Replace("'", "\'")
  31. Dim sqlquery = "SELECT * FROM accounts WHERE username = '" + Email + "'"
  32. SQL = "SELECT * FROM `accounts` WHERE `username` = '" + Email + "' and `password` = '" + motdepasse + "'"
  33.  
  34. myCommand.Connection = conn
  35. myCommand.CommandText = SQL
  36. myAdapter.SelectCommand = myCommand
  37. Try
  38. myData = myCommand.ExecuteReader()
  39. myData.Read()
  40.  
  41. If SQL = "SELECT * FROM accounts WHERE username = " + Email + " AND id " = 4 Then
  42. MsgBox("compte non abonner")
  43. ElseIf SQL = "SELECT * FROM accounts WHERE id = AND username=" + Email + "" Then
  44. MsgBox("compte abonner")
  45. End If
  46.  
  47. If myData.HasRows = 0 Then 'Si le mot de passe ou l'email ne correspond pas a se qu'il y a dans la BDD alors on affiche
  48. MsgBox("Il se peut que votre comptes soit invalide")
  49. myData.Close()
  50. Else 'Si le mot de passe et l'email correspond a un compte alors on affiche
  51. MsgBox("Bienvenue " + KryptonTextBox1.Text)
  52. myData.Close()
  53. Me.Visible = False
  54. InAppWindows.Show()
  55. End If
  56. Catch ex As MySqlException
  57. MsgBox(ex.Message)
  58. End Try
  59. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement