0
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...

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by sknake
0

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.

0
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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.