1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyConnexion As SqlConnection = New SqlConnection("Data Source=.\sqlexpress;" & _
"Integrated Security=SSPI;Initial Catalog=autoecole")
Dim Mycommand As SqlCommand = MyConnexion.CreateCommand()
Mycommand.CommandText = "SELECT * FROM charge"
MyConnexion.Open()
Dim myReader As SqlDataReader = Mycommand.ExecuteReader()
Do While myReader.Read()
ComboBox1.Items.Add(myReader.GetValue(0))
Loop
myReader.Close()
MyConnexion.Close()
End Sub |