DataBase.cs 859 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Data.SqlClient;
  7. namespace Servise
  8. {
  9. internal class DataBase
  10. {
  11. SqlConnection sqlConnection =new SqlConnection(@"Data Source=ngknn.ru;Initial Catalog=YPpract;Persist Security Info=True;User ID=31П;Password=12357");
  12. public void openConect()
  13. {
  14. if (sqlConnection.State == System.Data.ConnectionState.Closed)
  15. {
  16. sqlConnection.Open();
  17. }
  18. }
  19. public void closeConect()
  20. {
  21. if (sqlConnection.State == System.Data.ConnectionState.Open)
  22. {
  23. sqlConnection.Close();
  24. }
  25. }
  26. public SqlConnection getConect()
  27. {
  28. return sqlConnection;
  29. }
  30. }
  31. }