27 lines
599 B
C#
27 lines
599 B
C#
using Npgsql;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Management;
|
|
|
|
namespace DatenDB
|
|
{
|
|
static class DatenbankConnection
|
|
{
|
|
private static NpgsqlConnection connection = null;
|
|
|
|
public static NpgsqlConnection GetConnection()
|
|
{
|
|
if (connection?.State == System.Data.ConnectionState.Open) return connection;
|
|
connection?.Dispose();
|
|
connection = new NpgsqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
|
|
|
|
return connection;
|
|
}
|
|
|
|
}
|
|
}
|