• +91 9723535972
  • info@interviewmaterial.com

Ado.net Interview Questions and Answers

Ado.net Interview Questions and Answers

Question - 101 : - What you mean by Filtering of data?

Answer - 101 : -

Filtering of data is done when you need to display only selective records.

Given below are the  two methods for filtering data:

  • Creating parameterized queries.
  • Filtering data using control of a window form.

Question - 102 : - What do you mean by performing Asynchronous Operation using Command Object?

Answer - 102 : -

Sometimes the execution of the commands in the database may take a large amount of time to complete as they are linked to each other.

A solution for such a situation has asynchronously executed the commands against the database without waiting for the command execution to finish, which can be handy in the situation in which, when you try to execute the long-running base commands.

Advantages of Asynchronous Execution:

  • Improves performance.
  • Improve responsiveness of the client application.

Question - 103 : - What do you mean by ‘Batch Updates’?

Answer - 103 : -

A batch update can be defined as a batch of updates grouped together. To improve the performance of the data updates in a database is to update and send the changes in batches to the database, rather than one by one.

Advantages of Batch Updates:

  • Less network traffic is involved as data is sent in batches.
  • A database might be able to execute some of the updates in parallel.

Question - 104 : - What is the difference between Typed and Untyped Dataset?

Answer - 104 : -

The differences are explained below:

Typed Dataset: A typed dataset is derived from the Dataset class and has an associated XML schema, which is created at the time of creation of the dataset.

The XML schema contains information about the dataset structure such as tables, columns, and rows. Data is transferred from a database into a dataset and from the dataset to another component in the XML format.

Untyped Dataset: Untyped dataset doesn’t have an XML schema associated with it. Untyped Dataset, the tables, and columns are represented as a collection.

Question - 105 : - What are the major challenges in accessing data from a database?

Answer - 105 : -

The challenges include:

  • More than one user might need to access the data simultaneously from one database.
  • More than one user might need to access the data anytime, anywhere.
The solution to this problem is attained by implementing a ‘Database locking’ during the time of transaction execution.

Question - 106 : - What are two types of transactions supported by ADO.net?

Answer - 106 : -

Two types of Transaction supported by ADO.net

  • Local Transaction: A local transaction is based on a single data source. It will be handled directly by the database. For Example, We import ‘System.Data.SQL client’ namespace, if we need to perform data transaction using Sqlserver. Similarly, we import ‘System.Data.Oracle client’ namespace, if we are using Oracle database.
  • Distributed Transaction: If the user needs to perform a transaction across multiple data Servers like SQL Server, Oracle, etc he can use a distributed transaction.

Question - 107 : - What is the SqlCommandBuilder?

Answer - 107 : -

CommandBuilder helps you to generate update, delete, and insert commands on a single database table for a data adapter. Similar to other objects, each data provider has a command builder class. The OleDbCommandBuilder, SqlCommonBuilder, and OdbcCommandBuilder classes represent the CommonBuilder object in the OleDb, Sql, and ODBC data providers.

Creating a Command Builder Object:

Creating a CommonedBuider object is pretty simply. You pass a DataAdapter as an argument of the CommandBuilder constructor. For example,

  • // Create a command builder object
  • SqlCommandBuilder builder = new SqlCommandBuilder(adapter);

Question - 108 : - What is the Connection object in ADO.NET?

Answer - 108 : -

A Connection object sits between a data source and a DataAdapter (via Command). You need to define a data provider and a data source when you create a connection. With these two, you can also specify the user ID and password depending on the type of data source. Figure 3-3 shows the relationship between a connection, a data source, and a data adapter.
                            
Figure: The relationship between connection, data Adapter, and a data source.

Connection can also be connected to a Command object to execute SQL queries, which can be used to retrieve, add, update and delete data to a data source. Figure 2 shows the relationship between the Command and Connection objects.
           

Question - 109 : - Describe the DataView in ADO.NET?

Answer - 109 : -

A DataView enables you to create different views of the data stored in a DataTable, a capability that is often used in data binding applications. Using a DataView, you can expose the data in a table with different sort orders, and you can filter the data by row state or based on a filter expression. A DataView provides a dynamic view of data whose content, ordering, and membership reflect changes to the underlying DataTable as they occur. This is different from the Select method of the DataTable, which returns a DataRow array from a table per particular filter and/or sort order and whose content reflects changes to the underlying table, but whose membership and ordering remain static. The dynamic capabilities of the DataView make it ideal for data-binding applications.

How we can create a DataView

There are two ways to create a DataView. You can use the DataView constructor, or you can create a reference to the DefaultView property of the DataTable. The DataView constructor can be empty, or will also take either a DataTable as a single argument, or a DataTable along with filter criteria, sort criteria, and a row state filter.

  • DataView custDV = new DataView(customerDS.Tables["Customers"],
  • "Country = 'USA'",
  • "ContactName",
  • DataViewRowState.CurrentRows);
  • DataView custDV = customerDS.Tables["Customers"].DefaultView;

Question - 110 : - What is ExecuteScalar method in ADO.NET?

Answer - 110 : -

ExecuteScalar Method

The ExecuteScalar method of the SqlCommand object is useful for retrieving a single value from the database. In our example, we need to retrieve the total number of records in the Titles table of the Pubs database. Since the total number of records is a single scalar value, the Execute Scalar method is used. The following is the code and its explanation:

private void frmSqlCommand_Load(object sender, EventArgs e)
{
    //Sample 03: Open Database Connection
    String con_string = Properties.Settings.Default.ConStrPubs;
    pubs_db_connection = new SqlConnection(con_string);
    pubs_db_connection.Open();
    //Sample 04: Form the Command Object
    SqlCommand cmd = new SqlCommand();
    cmd.CommandText = "Select Count(*) as Count from Titles";
    cmd.Connection = pubs_db_connection;
    //Sample 05: Execute the Command & retrive scalar value
    lblTotal.Text = System.Convert.ToString(cmd.ExecuteScalar());
}


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners