Overview of ADO.NET architecture.
Data Provider provides objects through which functionalities like opening and closing connection, retrieving and updating data can be availed.
It also provides access to data source like SQL Server, Access, and Oracle).
Some of the data provider objects are:- Command object which is used to store procedures.
- Data Adapter which is a bridge between datastore and dataset.
- Datareader which reads data from data store in forward only mode.
- A dataset object is not in directly connected to any data store. It represents disconnected and cached data. The dataset communicates with Data adapter that fills up the dataset. Dataset can have one or more Datatable and relations.
- DataView object is used to sort and filter data in Datatable.
Overview of ADO.NET architecture.
ADO.NET provides access to all kind of data sources such as Microsoft SQL Server, OLEDB, Oracle, XML.
ADO.NET separates out the data access and data manipulation componenets. ADO.NET includes some providers from the .NET Framework to connect to the database, to execute commands, and finally to retrieve results. Those results are either directly used or can be put in dataset and manipulate it.
Define connected and disconnected data access in ADO.NET
Data reader is based on the connected architecture for data access. Does not allow data manipulation.
Dataset supports disconnected data access architecture. This gives better performance results.
Describe CommandType property of a SQLCommand in ADO.NET.
CommandType is a property of Command object which can be set to Text, Storedprocedure. If it is Text, the command executes the database query. When it is StoredProcedure, the command runs the stored procedure. A SqlCommand is an object that allows specifying what is to be performed in the database.
Access database at runtime using ADO.NET
SqlConnection sqlCon = new SqlConnection(connectionString)
sqlCon.Open();
string strQuery = "select CategoryName from abcd";
SqlCommand cmd = new SqlCommand(strQuery, conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader [0]);
}
reader.Close();
con.Close();