Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net SQLClient equivalent SQLClient equivalent of Oledb code

Hi. What is the SQLClient equivalent of the following code be

    Sub GetTableNames()

        Dim schemaTable As DataTable
        Dim i As Integer

        Dim cs As String = Globals.ThisAddIn.oRIGHT.lblConnectionString.Text
        Dim cn As New OleDbConnection(cs)
        Try
            cn.Open()

            'Retrieve schema information about tables.
            'Because tables include tables, views, and other objects,
            'restrict to just TABLE in the Object array of restrictions.
            schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, _
                          New Object() {Nothing, Nothing, Nothing, "TABLE"})

            'List the table name from each row in the schema table.
            Me.cmbTables.Items.Clear()
            Me.cmbTables.Items.Add("N/A")
            'Count = 0 'used to load arrays used for data types
            For i = 0 To schemaTable.Rows.Count - 1
                'Console.WriteLine(schemaTable.Rows(i)!TABLE_NAME.ToString)
                Me.cmbTables.Items.Add(schemaTable.Rows(i)!TABLE_NAME.ToString)
            Next i
            'Me.DropDownList_Table.SelectedIndex = 0

            'Explicitly close - don't wait on garbage collection.
            cn.Close()

            'Pause
            Console.ReadLine()
            cn = Nothing


        Catch
            'frmR.TopMost = False

            MsgBox("There was a problem getting table names! There may be a problem connecting to the online table." & Err.Description)
            'frmR.TopMost = True

        End Try
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

thanks very much