Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2745
  • Last Modified:

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


0
tovvenki
Asked:
tovvenki
1 Solution
 
Razzie_Commented:
I think PgAdmin III changed the name of your datasource. If you in Windows (XP), go to control panel, administrative tools, Data Sources (ODBC), you should change the driver={PostgreSQL} part to the exact name listed there, maybe it is driver={PostgreSQL 3.0} or something.

HTH,

Razzie
0
 
JigitCommented:
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
0
 
tovvenkiAuthor Commented:
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now