DataBase.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. /// <summary>
  12. /// установка соединения, указывается название сервера и входные данные
  13. /// </summary>
  14. SqlConnection sqlConnection = new SqlConnection(@"Data Source=ngknn.ru;Initial Catalog=YPpract;Persist Security Info=True;User ID=31П;Password=12357");
  15. public void openConect()
  16. {
  17. if (sqlConnection.State == System.Data.ConnectionState.Closed)
  18. {
  19. sqlConnection.Open();
  20. }
  21. }
  22. public void closeConect()
  23. {
  24. if (sqlConnection.State == System.Data.ConnectionState.Open)
  25. {
  26. sqlConnection.Close();
  27. }
  28. }
  29. public SqlConnection getConect()
  30. {
  31. return sqlConnection;
  32. }
  33. }
  34. }