-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnection.cs
More file actions
31 lines (27 loc) · 822 Bytes
/
Copy pathConnection.cs
File metadata and controls
31 lines (27 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Npgsql;
namespace C_
{
public class Connection
{
NpgsqlConnection conex = new NpgsqlConnection();
static string host = "localhost";
static string user = "postgres";
static string pass = "1234";
static string database = "henryapp";
static string port = "5432";
String conectionUrl = $"server={host}; port={port}; user id={user}; password={pass}; database = {database}";
public NpgsqlConnection connect(){
try
{
conex.ConnectionString = conectionUrl;
conex.Open();
Console.WriteLine("conection ready");
}
catch (NpgsqlException e)
{
Console.WriteLine(e.ToString());
}
return conex;
}
}
}