To access a SQL database in C#, you need to follow these steps:

1. Install the necessary NuGet package(s) to connect to the database. The most common package is `System.Data.SqlClient`, which provides the SQL Server-specific ADO.NET classes.

2. Import the required namespaces in your code:

“`csharp
using System.Data.SqlClient;
“`

3. Create a connection string that specifies the necessary details to connect to the database. The connection string contains the server name, database name, authentication method, and any other required information. Here’s an example:

“`csharp
string connectionString = “Server=myServerName;Database=myDatabaseName;Trusted_Connection=True;”;
“`

4. Establish a connection to the database using the connection string:

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

// Your code to interact with the database goes here

connection.Close();
}
“`

5. Execute SQL commands using a `SqlCommand` object. This object represents a SQL statement or stored procedure that you want to execute. Here’s an example of executing a simple SELECT statement:

“`csharp
string sqlCommandText = “SELECT * FROM MyTable”;
using (SqlCommand command = new SqlCommand(sqlCommandText, connection))
{
SqlDataReader reader = command.ExecuteReader();

while (reader.Read())
{
// Access the data using reader.GetString(), reader.GetInt32(), etc.
}

reader.Close();
}
“`

6. Once you have retrieved the data, you can perform any necessary operations on it.

7. Close the database connection when you are done. The `using` statement automatically closes the connection, but it’s good practice to include an explicit `Close()` call in case you need to modify the code later.

That’s it! You can now access a SQL database in C# using ADO.NET. Remember to handle any exceptions that may occur during the database operations.