check field

tirso

Active member
Joined
Nov 15, 2006
Messages
31
Programming Experience
1-3
I want to check all the field in my table if exist or not. Further more to count all the field. Any suggestion is greatly appreciated.

Tirso
 
What type of database you are using and what kind of connection you use to connect to your database? Different type of connection may be have different ways to retrieve the field list in the table. For example for oleDBConnection we use OleDb.OleDbConnection.GetOleDBSchemaTable function.

Dim schema2 as DataTable = m__oleDB.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Columns,
New Object() {Nothing, Nothing, "MyTable", Nothing})

And this is the reference

http://support.microsoft.com/kb/309488
 
I am using microsoft access database and oledbconnection. See the code below for the overview of using connection.

VB.NET:
    Private strConnection As String

    strConnection = ("Provider = Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source =" & txtDirectory.Text & ";")
 
    objConnection = New OleDbConnection(strConnection)

Tirso
 
Ok, then the reference should work well for you. You can retrieve the table's field with

Dim schema2 as DataTable = objConnection.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid .Columns, NewObject() {Nothing, Nothing, "YourTableName", Nothing})

And I hope I didn't mis-understand that the table you refer in the question is refer to the database table, and not the dataset table?
 
Back
Top