DB.cs 800 B

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