Find out weather a field exists

rmatthew

Well-known member
Joined
Dec 30, 2002
Messages
115
Location
Texas
I need to find out weather a field exists in database table (given the fieldname and the table name, and a connection string to the database). Any ideas - I cant find a method in the framework to accomplish this.

Thanks
 
You can use the Contains function in the Columns collection, e.g.

C#:
if (MyDataSet.Tables["Customer"].Columns.Contains("Name")) 
{
...do something
}
 
Back
Top