using System.Data.SqlClient; // Connection string to the database string connectionString = "Data Source=localhost;Initial Catalog=TestDB;Integrated Security=True"; // SQL query to retrieve data from the database string sql = "SELECT name, age FROM Users"; // Create a connection to the database using (SqlConnection connection = new SqlConnection(connectionString)) { // Create a command object to execute the SQL query using (SqlCommand command = new SqlCommand(sql, connection)) { // Open the connection to the database connection.Open(); // Execute the SQL query and get the IDataReader object using (IDataReader reader = command.ExecuteReader()) { // Loop through the rows in the data reader while (reader.Read()) { // Get the name value as a string string name = reader["name"].AsValueIn this example, we're connecting to an SQL Server database and executing a query to retrieve data from the "Users" table. We're using the AsValue method to retrieve the values of the "name" and "age" columns as strings and integers respectively. We can then use these values as we see fit. The package library for the IDataReader interface and AsValue method is the System.Data.Common namespace. This namespace is part of the .NET Framework and provides a common set of data access classes and interfaces for working with various data sources.(); // Get the age value as an integer int age = reader["age"].AsValue (); // Do something with the name and age values Console.WriteLine("Name: {0}, Age: {1}", name, age); } } } }