I\'m looking at working on a project which uses C#.NET (sitting on a windows box) as the primary language and PostgreSQL as the backend database (backend is sitting on a linux b
Just Go to Tool-->NuGet Package Manager-->Manager Nuget Package Manager
search for NpgSql and then select your project and click Install
sample Code
public void Demo()
{
NpgsqlConnection connection = new NpgsqlConnection();
connection = d_connection; // your connection string
connection.Open();
NpgsqlCommand cmd = new NpgsqlCommand();
try
{
cmd.Connection = connection;
cmd.CommandText = "select * from your table name";
cmd.CommandType = System.Data.CommandType.Text;
using (var dataReader = cmd.ExecuteReader())
{
while (dataReader.Read())
{
string answer= dataReader.IsDBNull(0) ? "" : dataReader.GetString(0);
}
dataReader.Dispose();
}
}
catch (Exception e)
{
}
finally
{
cmd.Dispose();
connection.Dispose();
}
}
Dont use upper case in postgreSql because its case sensitive.