Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using System.Configuration;
  2. using System.Data.SqlClient;
  3.  
  4. class PerdiemSQL
  5. {
  6. public void connectToDB(
  7. string commandString,
  8. string connectionStringKey = @"default")
  9. {
  10. string connectionString = ConfigurationManager.ConnectionStrings[connectionStringKey].ConnectionString;
  11. using(SqlConnection residentConnection = new SqlConnection(connectionString))
  12. {
  13. SqlCommand residentCommand = new SqlCommand(commandString, residentConnection);
  14. residentConnection.Open();
  15.  
  16. using (SqlDataReader residentReader = residentCommand.ExecuteReader())
  17. {
  18. while (residentReader.Read())
  19. {
  20. // pump pipe
  21. }
  22. }
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement