I have already managed to connect to the database, but I used the following code to connect.
static void Main(string[] args)
{
using (NpgsqlConnection conn= new NpgsqlConnection(
"Host=xxx.xx.xx.xxx;Port=5432;User Id=Admin;Password=postgres.1;Database=Test1;"))
{
conn.Open();
NpgsqlCommand cmd = new NpgsqlCommand("SELECT * FROM TABLE1", conn);
try
{
NpgsqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
for (int i = 0; i < dr.FieldCount; i++)
{
Console.Write("{0} \t", dr[i]);
}
Console.WriteLine();
}
dr.Close();
}
finally
{
conn.Close();
}
}
Console.ReadLine();
}
Apparently I have to somehow generate classes for the tables in the database and use those to connect instead of using NpgsqlCommand cmd = new NpgsqlCommand("SELECT * FROM TABLE1", conn);. Already tried using DbLinq's DbMetal, but I get the error message :
DbMetal : Server has closed connection.
I've been researching this, but I haven't found anything useful.
Please help if you can. It's kinda urgent.
Thanks in advance.