69 lines
1.8 KiB
C#
69 lines
1.8 KiB
C#
using System.Data;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using MahApps.Metro.Controls;
|
|
using Npgsql;
|
|
using Npgsql.Replication;
|
|
|
|
namespace PrototypWPFHAG;
|
|
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : MetroWindow
|
|
{
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
TestConnection();
|
|
Console.ReadKey();
|
|
|
|
}
|
|
|
|
private static void TestConnection()
|
|
{
|
|
using (NpgsqlConnection con = GetConnection())
|
|
{
|
|
con.Open();
|
|
if (con.State == ConnectionState.Open)
|
|
{
|
|
Console.WriteLine("Connected to Server");
|
|
}
|
|
}
|
|
}
|
|
private static NpgsqlConnection GetConnection()
|
|
{
|
|
return new NpgsqlConnection(@"Server=localhost;Port=5432;User Id=postgres;Password=postgres;Database=postgres;");
|
|
}
|
|
|
|
//class Program
|
|
//{
|
|
// static void Main(string[] args)
|
|
// {
|
|
// TestConnection();
|
|
// Console.ReadKey();
|
|
// }
|
|
// private static void TestConnection()
|
|
// {
|
|
// using(NpgsqlConnection con = GetConnection()){
|
|
// con.Open();
|
|
// if (con.State == ConnectionState.Open) {
|
|
// Console.WriteLine("Connected to Server");
|
|
// }
|
|
// }
|
|
// }
|
|
// private static NpgsqlConnection GetConnection()
|
|
// {
|
|
// return new NpgsqlConnection(@"Server=localhost;Port=5432;User Id=postgres;Password=postgres;Database=TestServer;");
|
|
// }
|
|
//}
|
|
} |