1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
   | 
Imports System.Data.SqlClient
Public Class form1
    Dim con As New SqlConnection
    Dim cmd As New SqlCommand
    Dim dr As SqlDataReader
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2008\Projects\file1\file1\Database2.mdf;Integrated Security=True;User Instance=True"
        cmd.Connection = con
        con.Open()
        cmd.CommandText = "select file from connexion where Login= '" & Connexion.TextBox1.Text & "' and MotPasse= '" & Connexion.TextBox2.Text & "'"
        dr = cmd.ExecuteReader
        If dr.HasRows Then
            If (si la colonne file de la table connexion contient a le bouton1 est activé)
                Me.Button1.Enabled = True
            ElseIf (si la colonne file de la table connexion contient b le bouton 2 est activé)
                Me.Button2.Enabled = True
            End If
        End If
    End Sub
End Class | 
Partager