Ado Net Interview Question And Answers

Question 38: What are the Connection object properties and Connection class members?

Answer: The Connection class has a connection string that opens a connection to the database. The connection string will vary depending upon the provider used. The connection strings typically contain a group of property-value pair to describe how to connect to a database. For an OleDbConnection, you have properties such as Provider and DataSource.

Property Description
ConnectionString Represent the connection string.
ConnectionTimeOut Waiting time while establishing a connection.
DataBase Name of the current database.
DataSource Location of the file name of the data source.
Provider Name of the OLE DB provider. This property is not available for Sql and ODBC data providers.
State Current state of the connection of type ConnectionState. (Table 5-17 describes the ConnectionState).
PacketSize Size of network packets. Available to only Sql data providers.
ServerVersion SQL server version. Available to only Sql data providers.
WorkStationId Database client ID. Available to only Sql data providers.

The connection can have different states such as open, closed, connecting, and so on. The ConnectionType enumeration defines the members of the ConnectionState.

Method Description
BeginTransaction Begins database transaction.
ChangeDatabase Changes databases for an open connection.
Close Closes an opened connection.
CreateCommand Creates and return a Command object depends on the data providers. For example, OleDb Connection returns OleDbCommand, and SqlConnection returns SqlCommand.
Open Open a new connection.
ReleaseObjectPool Represents that the connection pooling can be cleared when the provider is released. Available only for Ole Db data providers.

Question 27: Which namespaces are used for data access?

Answer: ADO.NET is a collection of managed libraries used by .NET applications for data source communication using a driver or provider.

ADO.NET provides libraries for the datasource communication under the following namespaces.

  • System.Data: This namespace is used for holding and managing data on a client machine.
  • System.Data.OleDb: This namespace can communicate with any data source like files, databases, indexing servers and so on using the “OleDb” Provider.
  • System.Data.SqlClient: This namespace can communicate with “SQL Server” database only using SqlClient Providers.
  • System.Data.OracleClient: This namespace can communicate with an “Oracle” database only using OracleClient Providers.
  • System.Data.ODBC: This namespace contains the same set of classes as the following:
    • Connection
    • Command
    • DataReader
    • DataAdaptar
    • CommandBuilder
    • Parameter
  • See for more detail:

    2 What is the difference between Dataset.clone and Dataset.copy?

    Dataset.clone object copies structure of the dataset including schemas, relations and constraints. This will not copy data in the table.

    Dataset.copy – Copies both structure and data from the table.

    What are the main differences between ADO.NET and the classic ADO?

    Following are the main differences between ADO and ADO.NET:

    ADO

    ADO.NET

    ADO has a recordset

    ADO.NET has a data set and a data adapter.

    ADO objects interact in binary mode.

    ADO.NET uses XML for passing data.

    ADO mainly supports connection-oriented models.

    ADO.NET works in a discontinuous manner.

    ADO gains information about data at runtime. This information is based on metadata; thus, making it a costly process.

    ADO.NET uses identified metadata at design time; thus offering a better runtime performance and more efficient runtime behavior.

    Only client-side cursors are allowed.

    Supports both server-side and client-side cursors.

    ado net interview question and answers

    ADO.NET Interview Questions and Answers

    Related Posts

    Leave a Reply

    Your email address will not be published. Required fields are marked *