473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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.

Thanks,

Hexman

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 = ""
cboTables.Items.Clear()

Dim cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dbPath & dbFileName & ";")
cn.Open()
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
cboxTables.Items.Add(dr.Item(2))
End If
Next

cn.Close()
End If

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Leepe | last post by:
example: I have a skill object that implements the XmlSerializable interface Implementing the getschema gives me some unwanted generations towards the wsdl.exe Reference.cs generation. skill is...
3
by: Peter Cresswell | last post by:
Hello everyone, I would like to serialize an object to XML. Currently my code will serialize all of the public properties that are value types, but not my public properties that have get...
1
by: nathan.gomez | last post by:
Thanks for your time. I've been trying to get a list of databases available on a mySQL server (local) using the OdbcConnection.GetSchema() function. Thus far I have only been able to get...
1
by: Chris | last post by:
Hi, I'm using the following code DataTable tables = ((OleDbConnection)oleconn).GetOleDbSchemaTable( OleDbSchemaGuid.Tables, new object { null, null, null, "TABLE" }); foreach (DataRow r in...
46
by: John | last post by:
Hi How can I check for existence of a certain table by name in and access database and if the table exists find the number of records in it? I guess I can access this information by setting up...
3
by: Markus Weber \(Megalith GmbH\) | last post by:
Hello! I just want to check with "ADO" and "SQLConnection" if a table exist and what columns the table have. Does somebody know how to do that? Thanks in Advance! Markus
0
by: Sebastijan | last post by:
Hi I am interested in DbConnection.GetSchema method of ODP.NET oracle library. When I call (to get primary keys metadata) DataTable pkeys = DbConnection.GetSchema("PrimaryKeys"... foreach...
3
by: HillBilly | last post by:
I could use a little help on this seemingly arcane objective.
0
by: sandeepsangshetty | last post by:
How do I create a drop down list which has the values from a database column. So I need this list to have values like" "Select distinct departmentname from Department" The Department name...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.