Results 1 to 1 of 1

Thread: [2008] Filling a combobox with data from Access Database using Dataset.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    22

    [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
    Last edited by vblover2008; Dec 17th, 2008 at 10:38 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width