Se afișează postările cu eticheta DataSet. Afișați toate postările
Se afișează postările cu eticheta DataSet. Afișați toate postările

luni, 25 august 2014

System.Data namespace C#

System.Data namespace contains classes that represent ADO.NET architecture. 
ADO.NET efficiently manages data from multiple data sources.

Examples:
  1. Populating DataSet and DataTable

Populating a DataSet and table from a DataAdapter C#

SQL Adapter to executes the SQL statement or stored procedure referenced in its SelectCommand and put the results into a table in the dataset.
Than you call data adapter's Fill method.  
If the dataset contains multiple tables, you should have separate data adapters for each table and must therefore fill each table separately.

Example: 

SqlConnection con = new SqlConnection("connString");
SqlCommand com = new SqlCommand("exec your_stored_procedure", con);
com.CommandTimeout = 30;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = com;
con.Open();
DataSet ds = new DataSet();
da.Fill(ds, "Data");
DataTable dt = ds.Tables[0];
con.Close(); 

DataSet C#

DataSet represents an in-memory cache of data.
DataSet consists of a collection of DataTable objects. 

Example: