.NET - ADO.NET Interview Questions


Q. What are the differences between ADO and ADO.NET?
A.
  • Although OLE DB is supported in ADO.NET, the .NET implementation does not rely on OLE DB providers but rather, uses.NET managed providers to bridge your application with different data sources.
  • ADO.NET does not support both dynamic and keyset server-side cursors. It only supports forward-only, read-only cursors.
  • The .NET connection object does not have an "Execute" method and can not be used to execute SQL commands against the database.
  • Unlike the ADO Recordset object which represents a single table at a time and is strongly tied to the database it is connected to, the DataSet object in .NET is completely isolated from any database implementation and in itself, can represent a hierarchy of data that resembles an RDBMS.
  The provided points are just a few of the differences as an accurate answer for this question can be a long discussion with an interviewer
top ^
Q. What are the differences between the Recordset and the DataSet objects?
A.
  • Tables represented by the object: The ADO Recordset object represents only one table at a given time, while the DataSet object in ADO.NET can represent any number of tables, keys, constraints and relations which makes it very much like an RDBMS.
  • Navigation: Navigating the Recordset object depend on the cursor used to create the object with limited functionality in moving back and forth while the DataSet represents data in “collections” that could be accessed through indexers in a random-access fashion
  • Connection Model: The Recordset is designed to work as a “connected object” with a server-side cursor in mind while the DataSet is designed to work as a disconnected object containing hierarchy of data in XML format.
  • Database Updates: Updating a database through the use of a Recordset object is direct since it is tied to the database. On the other hand, the DataSet as an independent data store must use a database-specific DataAdapter object to post updates to the database.
  There are also some differences that have to do with remoting, marshaling and serialization.
top ^
Q. Briefly describe the ADO.NET class architecture.
A. ADO.NET classes could be classified into two categories:
  1. Data-source specific:
    This category includes different "Data Provider" namespaces each tailored to deal with specific data source.
    .NET Framework 1.1 comes with support for the following data providers:
    • SQL Server .NET Data Provider
    • OLE DB .NET Data Provider
    • ODBC .NET Data Provider
    • .NET Data Provider for Oracle
    Each of these data providers includes the following main classes:
    • xxxConnection
    • xxxCommand
    • xxxDataReader
    • xxxDataAdapter
    The xxx prefix can be replaced by "Sql", "Ole", "Odbc" or "Oracle" depending on which data provider is being used.

  2. Non data-source specific:
    This category mainly includes the DataSet class which is physically and logically disconnected from any particular data source.
    The DataSet could be published as a result of running query, executing a stored procedure, reading from an xml file or even manually.
    When published from a database, it is published through a DataAdapter.
top ^