tom tom - 1 month ago 5
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?


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

foreach(DataRow dr in MyDataSet.Tables["MyTable"])