SqlConnection
noun
say it: “ESS-kyoo-EL kuh-NEK-shun” /ˌɛs kjuː ˈɛl kəˈnɛkʃən/
The ADO.NET class that opens a connection from a C# program to a SQL Server database.
What is SqlConnection in C#?
SqlConnection — The ADO.NET object that opens a connection to one SQL Server database, from a connection string. Create it with using, so the connection is closed for you when you're done.
using Microsoft.Data.SqlClient;
using SqlConnection connection = new(
"Server=localhost;Database=Northwind;Integrated Security=True;TrustServerCertificate=True");
connection.Open();
Console.WriteLine(connection.State); // Open
In a sentence
- “I wrapped the SqlConnection in a using statement so it closes when the method ends.”
Level: Journeyman · More C# terms at this level
Updated