Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public static class DatabaseUsage
  2. {
  3. //TODO
  4. //Create stored procedure (watch video online)
  5.  
  6.  
  7. //Stored the connection string in the object myConnection (it is static so it can be used by the static methods here)
  8. private SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["myDbConnection"].ToString());
  9.  
  10. //This is used to store the sql among the different methods
  11. private static SqlCommand myCommand = new SqlCommand();
  12.  
  13.  
  14. //Used to read data from the sql statements
  15. private static SqlDataReader myReader;
  16.  
  17.  
  18. //Opens a connection to the database
  19. public static void openDatabaseConnection()
  20. {
  21. myCommand.Connection = myConnection; //Scince the connection has to be opened before any methods can be run on the database, this will always be declared at the start
  22. myConnection.Open();
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement