Created
July 28, 2013 16:09
-
-
Save AlexArchive/6099114 to your computer and use it in GitHub Desktop.
Basic SQL Query From C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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