Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;Integrated Security=True;AttachDbFilename=c:usersnamedocumentsvisual studio 2013ProjectsDBSampleDBSampleDatabase1.mdf");
  2. SqlCommand cmd = new SqlCommand("Select * From Account", con);
  3. SqlDataReader rd= cmd.ExecuteReader(); ;
  4.  
  5. SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;Integrated Security=True;AttachDbFilename=c:usersnamedocumentsvisual studio 2013ProjectsDBSampleDBSampleDatabase1.mdf");
  6. SqlCommand cmd = new SqlCommand("Select * From Account", con);
  7. con.Open();
  8. SqlDataReader rd= cmd.ExecuteReader();
  9.  
  10. using (SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;Integrated Security=True;AttachDbFilename=c:usersnamedocumentsvisual studio 2013ProjectsDBSampleDBSampleDatabase1.mdf"))
  11. {
  12. using (SqlCommand cmd = new SqlCommand("Select * From Account", con))
  13. {
  14. // here the connection opens
  15. con.Open();
  16.  
  17. using (SqlDataReader rd = cmd.ExecuteReader())
  18. {
  19. // do your data reading here
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement