Overview
The System.Data
namespace provides access to classes that represent the core ADO.NET architecture. It includes base classes for data access, data manipulation, and in-memory data storage.
Common Types
SqlCommand
Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database.
Read more →Assembly
Assembly: System.Data.dll
<Reference Include="System.Data" />
Example: Retrieve Data with SqlConnection
// C# Example using System; using System.Data; using System.Data.SqlClient; class Program { static void Main() { var connectionString = "Server=.;Database=Northwind;Trusted_Connection=True;"; using var conn = new SqlConnection(connectionString); conn.Open(); var cmd = new SqlCommand("SELECT TOP 5 * FROM Customers", conn); using var reader = cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine($"{reader["CustomerID"]} - {reader["CompanyName"]}"); } } }