DB.cs 922 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace _02Trade
  8. {
  9. class DB
  10. {
  11. SqlConnection sqlconnection = new SqlConnection(@"Data Source=(localdb)\05Str; Initial Catalog=02Trade;Integrated Security=True");
  12. public void OpenConnection()
  13. {
  14. if (sqlconnection.State == System.Data.ConnectionState.Closed)
  15. {
  16. sqlconnection.Open();
  17. }
  18. }
  19. public void CloseConnection()
  20. {
  21. if (sqlconnection.State == System.Data.ConnectionState.Open)
  22. {
  23. sqlconnection.Close();
  24. }
  25. }
  26. public SqlConnection GetConnection()
  27. {
  28. return sqlconnection;
  29. }
  30. }
  31. }