using System.Data.SqlClient; // ... string connectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"; string query = "SELECT * FROM MyTable WHERE Id = @Id"; int id = 1; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@Id", id); connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { DateTime datetime = reader.ReadDateTime("MyDatetimeField"); Console.WriteLine("Datetime value: " + datetime.ToString()); } } }In this example, we connect to a database using a SQL Server connection string and execute a SELECT query to retrieve data from a table. We pass a parameter to the query to filter the results based on a specific ID value. We then use the SqlDataReader object to read the data returned by the query. Finally, we use the Server GenericReader ReadDateTime method to read the value of a datetime field named "MyDatetimeField". This code example uses the System.Data.SqlClient namespace, which is part of the .NET Framework Class Library.