What is ADO.NET?
ADO stands for ActiveX Data Object .ADO.NET is an object-oriented set of libraries that allows to interact with data sources. The data source is a database, but it could also be a text file, an Excel spreadsheet, or an XML file.ADO .NET consists of classes that allow a .NET application to connect to the data source, executes commands and manage disconnected data. One of the key Differences between ADO.NET and other database technologies is how it deals with Challenge with different data sources, that means, the code you use to connect to an SQL Database will not differ that much to the one connecting to an Oracle Database.Reply
Replied By: Name: Rajesh Kr
Define methods provided by the dataset object to generate XML in ADO.Net?
1.ReadXML: Read’s a XML document in to Dataset.
2.GetXML: This is a function, which returns the string containing XML document.
3.Writexml: This writes a XML data to disk.
Define Connection Pooling in brief?
Connection Pooling make a single connection instance, which allows that instance to connect to all the databases. It does not open and close the connection object multiple times.Reply
Difference between classic ADO and ADO.NET?
1.We have recordset in ADO and in ADO.NET we have dataset.
2.In recordset we can only have one table. If we want to accommodate more than one table we need to do inner join and fill the recordset. Dataset can have multiple tables.
3.All data persist in XML as compared to classic ADO where data persisted in Binary format also.
Explain the difference between an ADO.NET Dataset and an ADO Recordset?
1.Using dataset retrieve data from two databases like Oracle and SQL server and merge them in one dataset, with recordset this is not possible.
2.Recordset uses COM. But all representation of Dataset is using XML.
3.Dataset can be transmitted on HTTP while Recordset cannot be transmitted.
Define, how can we load multiple tables in a Dataset?
objCommand.CommandText = "Tab1"
objCommand.CommandText = "Tab2"
Above code shows how to load multiple Data Table objects in one Dataset object. Sample code shows two tables Tab1 and Tab2 in object ObjDataSet.
lstdata.DataSource = objDataSet.Tables("Tab1").DefaultView
In order to refer Tab1 Data Table, use Tables collection of Datasets and the Default view object will give you the necessary output.
What is the difference between “Dataset” and “DataReader”?
1.To cache data and pass to a different tier Dataset forms the best choice and it has decent XML support
2.Dataset is a disconnected architecture; DataReader has live connection while reading data.
3.To access data from more than one table Dataset forms the best choice.
4.If we need to move back while reading records, data reader does not support this functionality.
5.A biggest drawback of Dataset is speed. As Dataset carry considerable overhead because of relations, multiple table etc speed is slower than DataReader. Always try to use DataReader wherever possible, as it is meant especially for speed performance.
Compare the Connection-Oriented and Disconnected Scenario in ADO.Net?
1.Always accessing current data
2.Low number of concurrent data accesses
3.Many write accesses situation
4.IDbConnection, IDbCommand, IDataReader
1.Modification in Dataset is not equal to modification in data source
2.Many concurrent read accesses situation
3.Dataset, Data table, DbDataAdapter
What are the basic Namespaces in ADO.Net?
Some basic namespaces are:
1.System.Data (basics types)
2.System.Data.OleDb (OLEDB Provider)
3.System.Data.SqlClient (Microsoft Sql Server provider)
6.System.Data.Odbc (ODBC Provider)
7.System.Data.Odbc.OracleClient (Oracle Provider)
8.System.Data.SqlServerCe (Compact framework)
How to create a SqlDataAdapter in ADO.Net?
SqlDataAdapter holds the SQL commands and connection object for reading and writing data. It initializes with a SQL select statement and connection object:
SqlDataAdapter daStudent = new SqlDataAdapter(
"select StudentID, CollegeName from Students", conn);
The SQL select statement specifies what data will be read into a DataSet.
The connection object, conn, should have already been instantiated, but not opened.
SqlCommandBuilder is instantiated with a single constructor parameter of the SqlDataAdapter, daStudent, instance.
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daStudent);
SqlCommandBuilder will read the SQL select statement (specified when the SqlDataAdapter was instantiated), infer the insert, update, and delete commands.