ADO.NET Introduction

What is ADO.NET?

ADO.NET is the core data access technology for .NET. It provides a rich set of components for connecting to databases, executing commands, and retrieving results. ADO.NET works with relational databases (SQL Server, MySQL, PostgreSQL) and non‑relational stores (Azure Cosmos DB, ODBC).

Key Concepts

Getting Started

Below is a minimal example that connects to a SQL Server database, runs a query, and prints the results.

using System;
using System.Data.SqlClient;

class Program
{
    static void Main()
    {
        string connStr = "Server=localhost;Database=Demo;Integrated Security=true;";
        using (var connection = new SqlConnection(connStr))
        {
            connection.Open();
            string sql = "SELECT Id, Name FROM Customers;";
            using (var command = new SqlCommand(sql, connection))
            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    Console.WriteLine($"{reader["Id"]}: {reader["Name"]}");
                }
            }
        }
    }
}

Further Reading

Explore the following topics to deepen your knowledge: