Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports MySql.Data.MySqlClient
- Public Class Form1
- Dim conn As New MySqlConnection
- Private Function Connect(ByVal server As String, ByRef user As String, ByRef password As String, ByRef database As String)
- 'On se connecte avec les information donner
- conn.ConnectionString = "server=" + server + ";" _
- & "user id=" + user + ";" _
- & "password=" + password + ";" _
- & "database=" + database + ";"
- Try
- 'Si il y a aucune erreur on ouvre la connexion
- conn.Open()
- Return True
- Catch ex As MySqlException
- 'Si il y a une erreur on affiche le message suivant
- Return MsgBox("Aucune Connexion au Mysql")
- End Try
- End Function
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Connect("localhost", "root", "", "miniteck") 'On change si besoin
- End Sub
- Private Sub KryptonButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton1.Click
- Dim myCommand As New MySqlCommand
- Dim myAdapter As New MySqlDataAdapter
- Dim myData As MySqlDataReader
- Dim SQL As String
- Dim Email As String = KryptonTextBox1.Text.Replace("'", "\'")
- Dim motdepasse As String = KryptonTextBox2.Text.Replace("'", "\'")
- Dim sqlquery = "SELECT * FROM accounts WHERE username = '" + Email + "'"
- SQL = "SELECT * FROM `accounts` WHERE `username` = '" + Email + "' and `password` = '" + motdepasse + "'"
- myCommand.Connection = conn
- myCommand.CommandText = SQL
- myAdapter.SelectCommand = myCommand
- Try
- myData = myCommand.ExecuteReader()
- myData.Read()
- If SQL = "SELECT * FROM accounts WHERE username = " + Email + " AND id " = 4 Then
- MsgBox("compte non abonner")
- ElseIf SQL = "SELECT * FROM accounts WHERE id = AND username=" + Email + "" Then
- MsgBox("compte abonner")
- End If
- 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
- MsgBox("Il se peut que votre comptes soit invalide")
- myData.Close()
- Else 'Si le mot de passe et l'email correspond a un compte alors on affiche
- MsgBox("Bienvenue " + KryptonTextBox1.Text)
- myData.Close()
- Me.Visible = False
- InAppWindows.Show()
- End If
- Catch ex As MySqlException
- MsgBox(ex.Message)
- End Try
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement