12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Data.SqlClient;
- namespace Blanki_ekzamena
- {
- internal class DataBase
- {
- static SqlConnection SqlConnection = new SqlConnection(@"Data Source=ngknn.ru;Initial Catalog=31P_Trifonova_PP;User ID=31П;Password=12357");
- public static void openConnection()
- {
- if (SqlConnection.State == System.Data.ConnectionState.Closed)
- {
- SqlConnection.Open();
- }
- }
- public static void closeConnection()
- {
- if (SqlConnection.State == System.Data.ConnectionState.Open)
- {
- SqlConnection.Close();
- }
- }
- public static SqlConnection GetConnection()
- {
- return SqlConnection;
- }
- public static SqlConnection connect()
- {
- string location = Environment.CurrentDirectory;
- location = location.Remove(location.Length - 9, 9);
- location = location.Insert(location.Length, "Database1.mdf");
- string connectionString = @"Data Source=ngknn.ru;Initial Catalog=31P_Trifonova_PP;User ID=31П;Password=12357";
- SqlConnection sqlConnection = new SqlConnection(connectionString);
- sqlConnection.Open();
- return sqlConnection;
- }
- }
- }
|