using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Data; namespace Dataset { public class Customers { //Declare ADO.Net objects at class level private SqlConnection conn; private SqlDataAdapter da; private DataSet ds; private SqlCommandBuilder cb; public DataSet GetCustomers() { //Create connection to Northwind database conn = new SqlConnection(@"Data Source=.;Initial Catalog=Northwind;Integrated Security=True"); //Create a SQL statement to get rows from the customers table string queryString = "SELECT CustomerID, CompanyName FROM dbo.Customers"; //Create data adapter using the connection da = new SqlDataAdapter(queryString, conn); ds = new DataSet(); //Fill the dataset using the data adapter da.Fill(ds, "Customers"); return ds; } } }