Murray Brown
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.l blConnecti onString.T ext
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(Ole DbSchemaGu id.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(schemaT able.Rows( i)!TABLE_N AME.ToStri ng)
Me.cmbTables.Items.Add(sch emaTable.R ows(i)!TAB LE_NAME.To String)
Next i
'Me.DropDownList_Table.Sel ectedIndex = 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
Sub GetTableNames()
Dim schemaTable As DataTable
Dim i As Integer
Dim cs As String = Globals.ThisAddIn.oRIGHT.l
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(Ole
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/
'Count = 0 'used to load arrays used for data types
For i = 0 To schemaTable.Rows.Count - 1
'Console.WriteLine(schemaT
Me.cmbTables.Items.Add(sch
Next i
'Me.DropDownList_Table.Sel
'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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER