Working of a DataAdapter:
protected void
Page_Load(object sender, EventArgs e)
{
//Windows Authentication
String ConnectionString = "server=localhost;
database=AdventureWorks; Integrated Security=True";
SqlConnection conn = new
SqlConnection(ConnectionString);
conn.Open();
string qryString = "SELECT
TOP 10 * FROM Person.Contact";
SqlDataAdapter da = new
SqlDataAdapter(qryString, conn);
DataSet ds = new DataSet();
da.Fill(ds, "Employee");
}
DataSet
Component:
A DataSet
is the component responsible for disconnected data architecture. Every DataTable of a DataSet contains Columns
collection of DataColumn object and the Rows collection of DataRow objects.
The
DataRow contains actual field values and these field values can be accessed
field name, like inmyRow[“FiledName”].
The data
in the data source is never touched at all when you are working with the
DataSet objects. Instead, all the changes are done locally to the DataSet in
memory. Then the changes which are made into the DataSet will be updated in the
actual database.


No comments:
Post a Comment