Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created July 28, 2013 16:09
Show Gist options
  • Save AlexArchive/6099114 to your computer and use it in GitHub Desktop.
Save AlexArchive/6099114 to your computer and use it in GitHub Desktop.
Basic SQL Query From C#
const string ConnectionString =
"Data Source=DESKTOPPC;Initial Catalog=TSQL2012;Integrated Security=True";
using (var connection = new SqlConnection(ConnectionString))
{
const string Query = "SELECT * FROM Sales.Orders WHERE custid = 71;";
using (var adapter = new SqlDataAdapter(Query, connection))
{
var result = new DataTable();
connection.Open();
adapter.Fill(result);
}
connection.Open();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment