471,078 Members | 844 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,078 software developers and data experts.

How to get Table Properties??? GetSchema???

Hello All,

I am wanting to make a small utility that allows the user (me) to select a local database (currently Access 2000), build a list of non-system tables,
then select a table which will then populate a datagridview with the column name, default, null, if primary key, etc......

I've seen the code for obtaining this info before, but can't rememeber where. Can anyone help? Using vb.net 2005.

The code below allows the user to select a db file and adds each non-system table to a combo box. After browsing thru the combo box, I need the code
to retrieve into a dataset all the columns with properties of the selected table.



I started with this to get the table:
================================================== ==========
Dim dbPath As String = "C:\"
Dim dbFileName As String = "Test.mdb"

Dim ofdDataBases As New OpenFileDialog()
ofdDataBases.Title = "Display Database Table Structure"
ofdDataBases.InitialDirectory = "C:\"
ofdDataBases.Filter = "All files (*.*)|*.*|MDB files (*.mdb)|*.mdb"
ofdDataBases.FilterIndex = 2
ofdDataBases.RestoreDirectory = True

If ofdDataBases.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
tbDatabase.Text = ofdDataBases.FileName
tbPrefix.Text = ""

Dim cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dbPath & dbFileName & ";")
Dim dt As New DataTable
Dim dr As DataRow
dt = cn.GetSchema("Tables")
For Each dr In dt.Rows
If dr.Item(3) = "TABLE" Then 'Only select user tables, not system tables
End If

End If

================================================== ==========
Jan 17 '07 #1
0 5500

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by nathan.gomez | last post: by
1 post views Thread by Chris | last post: by
46 posts views Thread by John | last post: by
3 posts views Thread by Markus Weber \(Megalith GmbH\) | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.