Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Does dataset have a column?
Message
From
17/07/2014 20:44:36
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01603979
Message ID:
01603983
Views:
38
Likes (1)
>Hi,
>
>What is the fastest (or an efficient) method to find out if a dataset (not strongly typed) has a column; by name. For example; I have a dataset MyDataSet (created by loading an XML file) and I want to find out if the dataset has column MyColumn.
>
>TIA

You can try Table.Columns.Contains(columnnameToTest), which returns a Boolean.

Here's an example....the first one returns true, the second one false
DataTable dt = new DataTable();
dt.Columns.Add("Column1", typeof(System.String));

MessageBox.Show( dt.Columns.Contains("Column1").ToString());
MessageBox.Show(dt.Columns.Contains("Column2").ToString());  
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform