[2008] Filling a combobox with data from Access Database using Dataset.
Hi
I have a problem filling the second column data from table REG, by using form1.Dataset.table. during the load of form2.
form1: contains a datagridview of the table REG.
STUDENTREGDataSet: is my database set, I tested the connection it is successful and I can see the data of table REG on form1 and I can browse them by using the navigator so I think the connection is fine.
I don't have any errors on this code but the combobox is still empty after loading the form.
I sould fill the combo box with non-repeated data. so that's why I put this line:
Code:
If (Combobox1.Items.IndexOf(S) = -1) Then
Combobox1.Items.Add(S)
End If
with or without that code the data is not filling.
my code is like this:
Code:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim S As String 'the field is as Text in the Access Database
Dim I As String
With Form1.STUDENTREGDataSet.REG
For I = 0 To .Rows.Count - 1
S = .Rows(I).Item(1)
If (Combobox1.Items.IndexOf(S) = -1) Then
Combobox1.Items.Add(S)
End If
Next
End With
End Sub
and in form1 I have this code it's automatically written:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'STUDENTREGDataSet.REG' table. You can move, or remove it, as needed.
Me.REGTableAdapter.Fill(Me.STUDENTREGDataSet.REG)
End Sub
can you help me please?? I'm new in VB.NET 2008.
thanks