Link to home
Start Free TrialLog in
Avatar of tovvenki
tovvenki

asked on

Unable to connect to postgres using Ado.net 1.1

Hi All,
I am trying to connect to postgres from my app using ado.net 1.1 but it always throws the error
"ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
the problem is the same code worked when I was using pgAdmin 2. I recently installed PgAdmin III and then the app starts failing to connect to my postgres database. The same is the sample code that I was testing
string sMyConnectionString = "driver={PostgreSQL};Server=192.168.0.33;Database=Piba.Net;UID=postgres;PWD=;";
OdbcConnection objLConnection = new OdbcConnection(sMyConnectionString);
try
{
      objLConnection.Open();
}
catch (Exception ex)
{
      Console.WriteLine(ex.Message);

}
objLConnection.Close();

Can anyone help me in solving the problem.

Thanks in advance

Venki


ASKER CERTIFIED SOLUTION
Avatar of Razzie_
Razzie_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Connection string for Core Labs PostgreSQLDirect (.NET):
"User ID=root; Password=pwd; Host=localhost; Port=5432; Database=testdb;Pooling=true; Min Pool Size=0; Max Pool Size=100; Connection Lifetime=0"
For more details: http://www.crlab.com/pgsqlnet/

HTH,
Jigit
Avatar of tovvenki
tovvenki

ASKER

HI All,
Thanks for your quick replies, in fact Razzie's post was very useful, it was the driver after installing pgAdmin III I have updated the driver and was now able to connect to the postgres server.

Regards,
Venki