Bonjour à tous,
Je suis sur un projet et j'ai ajouter une connexion via la base de donner.
J'utilise Mysql.
Tout fonctionne mes j'aimerais ajouter lorsque la personne se connecte le logiciel va regarder dans la bdd si l'utilisateur à la key = 1
si il à la key = 0 alors il se connecte pas c'est la que survient le problème je ne trouve pas comment faire pour que le logiciel regarde si le compte à la key.
Pouvez vous m'aider ?
Voici mon code pour la connexion :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
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("'", "\'")
        SQL = "SELECT * FROM `accounts` WHERE `username` = '" + Email + "' and `password` = '" + motdepasse + "'"
 
        Try
            myData = myCommand.ExecuteReader()
            myData.Read()
 
 
 
            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
Merci pour votre aide.