What is ADO.NET?What are the key components of ADO.NET?What are the ADO.NET namespaces?What is the meaning of object pooling?What are the differences between ADO.NET and classic ADO?Explain the architecture of ADO.NET.?What is a Connection String in ADO.NET C#??How do you establish a database connection using ADO.NET?Explain the concept of Connection Pooling in ADO.NET C#.Differentiate between Object pooling and Connection pooling in C#?What is a DataReader in ADO.NET? Explain with C# example?What is the functionality of CommandBehavior.SchemaOnly?Why CommandBehavior.SingleResult flag is used in ADO.NET?What does CommandBehavior.SingleRow do in ADO.NET?How we can get multiple results by DataReader using same connection in C#?How can we force the connection object to close after my DataReader is closed?What is a DataSet in ADO.NET? Explain with C# example?What are typed and un-typed datasets in ADO.NET C#?Write down some of the characteristic of DataSet?What is the difference between dataSet and DataReader?Why is DataSet Slower than DataReader? Explain with Example.How does DataSet handle data in a disconnected environment?What is the Difference between connected and disconnected architectire?Explain HasChanges() method of DataSet in C#.Explain GetChanges() method with detaild C# Example.Explain RejectChanges() method with C# Example.Explain AcceptChanges() method with C# Example.What are the various methods provided by DataSet for XML in C#?What is the purpose of DataAdapter in ADO.NET?Explain the steps involved in retrieving data using DataAdapter.

What is ADO.NET?

ADO.NET (ActiveX Data Objects .NET) is a data access technology in the .NET framework that provides a set of classes and APIs for accessing and manipulating data from various data sources, such as databases, XML files, and web services. ADO.NET allows developers to build data-driven applications by providing a way to connect to data sources, retrieve data, perform data manipulation operations, and update data.

Here's a simple C# example that demonstrates how to use ADO.NET to connect to a database, retrieve data from a table, and display it:


using System;
using System.Data;
using System.Data.SqlClient;

class Program
{
    static void Main(string[] args)
    {
        string connectionString = "Data Source=YourServer;Initial Catalog=YourDatabase;Integrated Security=True";

        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            connection.Open();

            string sqlQuery = "SELECT FirstName, LastName, Email FROM Customers";

            using (SqlCommand command = new SqlCommand(sqlQuery, connection))
            {
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string firstName = reader["FirstName"].ToString();
                        string lastName = reader["LastName"].ToString();
                        string email = reader["Email"].ToString();

                        Console.WriteLine("Name: " + firstName + " " + lastName);
                        Console.WriteLine("Email: " + email);
                        Console.WriteLine();
                    }
                }
            }
        }

        Console.ReadLine();
    }
}

In this example, we first establish a connection to the database by creating a SqlConnection object and providing the connection string that specifies the server, database, and authentication details.

We then define an SQL query to select data from the "Customers" table. We create a SqlCommand object, passing in the SQL query and the connection object.

Next, we execute the query using the ExecuteReader() method, which returns a SqlDataReader object. We iterate over the data using a while loop and retrieve the values of each column using the column names or indexes.

Finally, we display the retrieved data in the console.

Note: Remember to replace "YourServer" and "YourDatabase" in the connection string with the appropriate server and database names.

This example showcases a basic usage of ADO.NET to retrieve data from a database. ADO.NET provides many more features and capabilities, such as data insertion, updating, and deletion, handling transactions, and working with different data sources.