tom tom - 1 year ago 84
C# Question

How to read data from SQL Server database using Data Set / Data Adapter?

I am trying to do a simple thing, display data from a table that is in a SQL Server database.

I used the Data Source tab to add a Data Set and configure the Data Adapter.

The structure in Data Sources tab looks like this :

- MyTable
-- ColumnA
-- ColumnB
-- ColumnC

Now I would like to get all the values from
and write them to the console, basically
select ColumnB from MyTable

How do I do that using the Data Set / Data Adapter?

Answer Source

As per my understanding of your question, the below may help you:

foreach(DataRow dr in MyDataSet.Tables["MyTable"])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download