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
|
Imports MySql.Data.MySqlClient
Public Class Form1
Dim con As MySqlConnection = New MySqlConnection("Data Source=127.0.0.1;Database=connexion_excel;User ID=filou;Password=coucoucelui;")
'Dim sql As MySqlCommand = New MySqlCommand("SELECT nom, prenom, DN FROM table_test ORDER by nom ASC;", con)
'Dim a As String = TextBox1.Text
Dim sql As MySqlCommand = New MySqlCommand("SELECT nom, prenom, DN FROM table_test WHERE nom LIKE '" & TextBox1.Text & "%' ORDER by nom ASC;", con)
Dim ds As DataSet = New DataSet()
Dim DataAdapter1 As MySqlDataAdapter = New MySqlDataAdapter()
Dim Comb As MySqlCommandBuilder
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
con.Open()
Dim reader As MySqlDataReader
reader = sql.ExecuteReader()
While reader.Read()
ListBox1.Items.Add(reader.GetString("nom") & " " & _
reader.GetString("prenom") & " " & reader.GetString("DN"))
End While
reader.Close()
con.Close()
End Sub
End Class |