DataSet.Read : DataSet « System.Data « C# / C Sharp by API






DataSet.Read

  

using System;
using System.Data;            // Use ADO.NET namespace
using System.Data.SqlClient;  // Use SQL Server data provider namespace
using System.Collections.Generic;
using System.Text;

class Program {
    static void Main(string[] args) {
        SqlConnection thisConnection = new SqlConnection(
            @"Server=(local)\sqlexpress;Integrated Security=True;" +
          "Database=northwind");

        SqlDataAdapter thisAdapter = new SqlDataAdapter(
             "SELECT CustomerID, ContactName FROM Customers", thisConnection);

        DataSet thisDataSet = new DataSet();

        thisAdapter.Fill(thisDataSet, "Customers");
        foreach (DataRow theRow in thisDataSet.Tables["Customers"].Rows) {
            Console.WriteLine(theRow["CustomerID"] + "\t" +
                                                  theRow["ContactName"]);
        }

        thisConnection.Close();
    }
}

   
    
  








Related examples in the same category

1.new DataSet(String data)
2.DataSet.Delete
3.DataSet.Merge
4.DataSet.MergeFailed
5.DataSet.ReadXml
6.DataSet.Relations.Add
7.DataSet.Tables
8.DataSet.WriteXml