Multiple Result Sets Processing in Ado.net

About ADO.Net Multiple ResultSet Processing Example

In this Example, we will see packing more than one SQL statement in a SqlCommand and process it through the SqlDataReader object. From the past articles on ado.net we are already familiar with Connection, Command and Reader objects. Hence, we will focus on dealing with multiple result sets.

The example retrieves the data from the SQL Server sample database Pubs. A total number of authors queried from the table authors is displayed in a label control marked as 1 and author name from the same table is displayed in the combo box item marked as 2. The list box marked as 3 displays all store names by querying the table stores from the Pubs database. When we click the Get Data button (Marked as 4), the example fetches all the data through a single SqlCommand formed by three SQL statements.

Read More

How do I use ExecuteScalar in C#?

Execute Scalar Block Diagram

In this Article, we will use ExecuteScalar function to find the number of records in a table. The article uses employees table from NorthWnd database. But still one can use any table in any database while proceeding through the article.

Read More