Skip to content

Instantly share code, notes, and snippets.

@a7madev
Created January 2, 2015 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a7madev/b8d5e613f70ba68c35ae to your computer and use it in GitHub Desktop.
Save a7madev/b8d5e613f70ba68c35ae to your computer and use it in GitHub Desktop.
C# Retrieve Data from Database
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();
cmd.Connection=con;
cmd.CommandType=CommandType.Text;
cmd.CommandText="select column from table where condition;";
con.ConnectionString=  projectname.Properties.Settings.Default.DatabaseNameConnectionString;
SqlDataReader myReader;
con.Open();
myReader= cmd.ExecuteReader();
 
con.Close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment