C# .NET ===> postgreSQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smurphy811
    New Member
    • Mar 2007
    • 2

    C# .NET ===> postgreSQL

    I am creating a C# .NET application that uses a postgreSQL database that is on my machine locally. My problem is that I cannot figure out how to write the connectionStrin g. I have searched the internet for the past 30 minutes trying everything I could find.

    Help? anyone?


    Code:
    public class Connection
    {
    	protected static SqlConnection conn;
    	private const string connStr = "???";
    	
    	public static SqlConnection getConnection()
    	{
    		if(conn == null)
    		{
    			conn = new SqlConnection(connStr);
    			conn.Open();
    		}
    		return conn;
    	}
    }
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    You can use odbc or npgsql. Here is an example using Npgsql:
    Code:
    String connstring = "Server=xx.xx.xx.xx;Port=5432;User
    id=user;Password=password;Database=dbname";

    Comment

    Working...