Dim SchemaTable As DataTable
        Try
            NewFaceOptions.comboselecttable.Items.Clear()
            SchemaTable = createConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, _
            New Object() {Nothing, Nothing, Nothing, Nothing})
            Dim int As Integer
            For int = 0 To SchemaTable.Rows.Count - 1
                If SchemaTable.Rows(int)!TABLE_TYPE.ToString = "TABLE" Then
                    'Add items to list box
                    NewFaceOptions.comboselecttable.Items.Add(SchemaTable.Rows(int)!TABLE_NAME.ToString())
                End If
            Next

        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString(), "Data Load Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try

my point is that while this code runs fine, but when i go back to a previous form, select a different database and the proceed to this form again the table list remains the same that of the previous database.

i have tried ::

me.dispose()

on the cancel button but still the problem persists.
plz help...

It sounds like you're not updating "createConnection" with the value selected on the previous form. You probably need to upload a project so we can take a look at it. The problem you're describing is occuring outside the scope of the code you posted.

Module dataconnection

    Private createConnection As New OleDb.OleDbConnection()
   'Dim newConnection As New OleDb.OleDbConnection()
    Dim DatabasePath As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", Mainform.ofdselectdatabase.FileName)
    Public Sub createlistconn()
        'newConnection.ConnectionString() = DatabasePath
        createConnection.ConnectionString() = DatabasePath
        createConnection.Open()
    End Sub

    Public Sub closelistconn()
        createConnection.Close()
        createConnection.Dispose()
    End Sub

    Public Sub tablelist()
        createlistconn()
        Dim SchemaTable As DataTable
        Try
            NewFaceOptions.comboselecttable.Items.Clear()
            SchemaTable = createConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, _
            New Object() {Nothing, Nothing, Nothing, Nothing})
            Dim int As Integer
            For int = 0 To SchemaTable.Rows.Count - 1
                If SchemaTable.Rows(int)!TABLE_TYPE.ToString = "TABLE" Then
                    'Add items to list box
                    NewFaceOptions.comboselecttable.Items.Add(SchemaTable.Rows(int)!TABLE_NAME.ToString())
                End If
            Next

        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString(), "Data Load Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
        closelistconn()
    End Sub
End Module

Upload your project. I'm not seeing an obvious problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.