Skip to content

Microsoft.Data.SqlClient

Sann Lynn Htun edited this page Nov 19, 2024 · 6 revisions

Microsoft.Data.SqlClient

Microsoft.Data.SqlClient provides data access for Microsoft SQL Server and Azure SQL Database.

Example

using System;
using Microsoft.Data.SqlClient;

class Program
{
    static void Main()
    {
        string connectionString = "your_connection_string";
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            connection.Open();
            string query = "SELECT * FROM Users";
            SqlCommand command = new SqlCommand(query, connection);
            using (SqlDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    Console.WriteLine($"{reader["Id"]}, {reader["Name"]}");
                }
            }
        }
    }
}

C# Basics Wiki

Core Concepts

Object-Oriented Programming (OOP)

Advanced Topics

Miscellaneous

Tools and Resources

Clone this wiki locally