vb.net:Loading ms access tables in combobox

May 1, 2011 at 16:12:50
Specs: Windows XP
I was hoping someone could offer me some help please
when i load the tables in combobox it displays other names such as
is there anyway i could fix the error
Private con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\testdb.accdb;Persist Security Info=False")

    Private adapter As New OleDbDataAdapter(String.Empty, Me.con)
    Private data As DataTable

    Private Sub Form1_Load(ByVal sender As Object, _
                       ByVal e As EventArgs) Handles MyBase.Load

        Me.ComboBox1.DisplayMember = "TABLE_NAME"
        Me.ComboBox1.ValueMember = "TABLE_NAME"
        Me.ComboBox1.DataSource = Me.con.GetSchema("TABLES")
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, _
                                           ByVal e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        If Me.ComboBox1.SelectedItem IsNot Nothing Then
            Me.data = New DataTable
            Me.adapter.SelectCommand.CommandText = String.Format("SELECT * FROM [{0}]", Me.ComboBox1.SelectedValue)

            Me.DataGridView1.DataSource = Nothing
            Me.DataGridView1.DataSource = Me.data
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As Object, _
                           ByVal e As EventArgs) Handles Button1.Click
        If Me.data IsNot Nothing Then
            Dim builder As New OleDbCommandBuilder(Me.adapter)
        End If
    End Sub

See More: vb.net:Loading ms access tables in combobox

May 2, 2011 at 06:08:58
I'm not entirely sure what you're asking for, but you can pick which columns you want. How you do so depends on how you're binding your data. It might be as simple as going though and removing whatever column you don't want after the fact.

How To Ask Questions The Smart Way

Report •

May 2, 2011 at 21:25:13
Thanks for reply
I am absolate new to vb.net , what i want is to display only tables list anf get rid of other list .still confused on how to do it

Report •
Related Solutions

Ask Question