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
|
Dim i As Integer = 0
Dim con As SqlClient.SqlConnection = Nothing
Dim command As SqlClient.SqlCommand = Nothing
Dim cs As String = "connexion à ta base"
Dim dr As SqlClient.SqlDataReader = Nothing
For i = 0 To 10
Dim c As New ComboBox
c.Location = New Point(10, 30 * i)
c.Name = "Combobox" & i.ToString
c.Width = 156
c.Height = 21
'c.Items.Add("test")
Me.Controls.Add(c)
con = New SqlClient.SqlConnection(cs)
command = New SqlClient.SqlCommand("SELECT champ FROM table", con)
con.Open()
dr = command.ExecuteReader()
If dr.HasRows Then
While dr.Read
c.Items.Add(dr.GetValue(0))
End While
End If
dr.Close()
con.Close()
Next |
Partager