The following code will put all the table information in a datagrid and
indicate the number of tables of all table types.
'need reference to ADODB
Try
Dim Conn As New ADODB.Connection
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Application.StartupPath & "\test.mdb"
Conn.Open()
Dim rs As New ADODB.Recordset
rs = Conn.OpenSchema(ADODB.SchemaEnum.adSchemaTables)
Dim MyTable As New DataTable
Dim da As New Data.OleDb.OleDbDataAdapter
da.Fill(MyTable, rs)
Me.DataGrid1.DataSource = MyTable
Me.DataGrid1.Refresh()
MsgBox(MyTable.Rows.Count.ToString)
Catch ex As Exception
MsgBox(ex.Message)
End Try
"Lokanath" <it*******@yahoo.com> wrote in message
news:44**********************************@microsof t.com...
Hi,
I am upgrading my database componenet from VB6.0 to VB.net but would like
to use ADO for database operation. Am trying to retrieve no of tables in a
database using connection.openschema method of ADODB. It works fine in VB6.0
but blows of in VB.net. The code looks like rsReadOnly = New ADODB.Recordset
rsReadOnly =
goConnection.OpenSchema(ADODB.SchemaEnum.adSchemaT ables, New Object()
{Nothing, Nothing, Nothing, "TABLE"}) The Error message is :System.NullReferenceException - Object
variable or With block variable not set.
Very Urgent........
--
System Analyst