36 lines
941 B
C#
36 lines
941 B
C#
using MySql.Data.MySqlClient;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace NeshinaPolina07_11
|
|
{
|
|
internal class DB
|
|
{
|
|
private static DB instance;
|
|
private MySqlConnection connection;
|
|
|
|
private readonly string connectionString =
|
|
"server=192.168.201.207;port=3306;username=ISP41_Neshina;password=ISP41_Neshina;database=ISP41_Neshina_13;SslMode=none;Charset=utf8mb4";
|
|
|
|
private DB()
|
|
{
|
|
connection = new MySqlConnection(connectionString);
|
|
OpenConnection();
|
|
}
|
|
|
|
public static DB GetInstance()
|
|
{
|
|
if (instance == null)
|
|
instance = new DB();
|
|
return instance;
|
|
}
|
|
|
|
public void OpenConnection()
|
|
{
|
|
if (connection.State == ConnectionState.Closed)
|
|
connection.Open();
|
|
}
|
|
|
|
public MySqlConnection GetConnection() => connection;
|
|
}
|
|
} |