473,378 Members | 1,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 connectionString. I have searched the internet for the past 30 minutes trying everything I could find.

Help? anyone?


Expand|Select|Wrap|Line Numbers
  1.  
  2. public class Connection
  3. {
  4.     protected static SqlConnection conn;
  5.     private const string connStr = "???";
  6.  
  7.     public static SqlConnection getConnection()
  8.     {
  9.         if(conn == null)
  10.         {
  11.             conn = new SqlConnection(connStr);
  12.             conn.Open();
  13.         }
  14.         return conn;
  15.     }
  16. }
  17.  
Mar 11 '07 #1
4 22173
michaelb
534 Expert 512MB
You probably want to look at the Postgres` Client Interfaces, especially libpq - C library and this Example Program
Mar 11 '07 #2
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 connectionString. I have searched the internet for the past 30 minutes trying everything I could find.

Help? anyone?


Expand|Select|Wrap|Line Numbers
  1.  
  2. public class Connection
  3. {
  4.     protected static SqlConnection conn;
  5.     private const string connStr = "???";
  6.  
  7.     public static SqlConnection getConnection()
  8.     {
  9.         if(conn == null)
  10.         {
  11.             conn = new SqlConnection(connStr);
  12.             conn.Open();
  13.         }
  14.         return conn;
  15.     }
  16. }
  17.  
use odbc connection class.
you r using sqlconnection class.
Mar 20 '07 #3
agasca
5
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 connectionString. I have searched the internet for the past 30 minutes trying everything I could find.

Help? anyone?


Expand|Select|Wrap|Line Numbers
  1.  
  2. public class Connection
  3. {
  4.     protected static SqlConnection conn;
  5.     private const string connStr = "???";
  6.  
  7.     public static SqlConnection getConnection()
  8.     {
  9.         if(conn == null)
  10.         {
  11.             conn = new SqlConnection(connStr);
  12.             conn.Open();
  13.         }
  14.         return conn;
  15.     }
  16. }
  17.  
Do you consider to use npgsql ?

with that you can connect to the database simply making this (example from the user manual):

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data;
  3. using Npgsql;
  4.  
  5. public class NpgsqlUserManual
  6. {
  7.   public static void Main(String[] args)
  8.   {
  9.     NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;");
  10.     conn.Open();
  11.     conn.Close();
  12.   }
  13. }
  14.  
Mar 31 '07 #4
nmadct
83 Expert
There's also an OLEDB interface to PostgreSQL:

http://pgfoundry.org/projects/oledb/

I'd think Npgsql should be more efficient if you care a lot about performance, though.
Apr 2 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Levent | last post by:
Folks, I am getting following message from pear. I am running RedHat 8.0, PostgreSQL is 7.3.2 PHP Version 4.2.2 and pear:db 1.6.5. Warning: pg_errormessage(): supplied argument is not a valid...
2
by: Rene Pijlman | last post by:
I can't seem to find any way to specify the character encoding with the DB API implementation of PyPgSQL. There is no mention of encoding and Unicode in the DB API v2.0 spec and the PyPgSQL README....
2
by: aum | last post by:
Hi, I'm looking for an object-relational layer, which can wrap a MySQL database into highly pythonic objects. There seem to be dozens of packages which provide some of this functionality, but...
12
by: Sander Smeenk | last post by:
Hi, After a very recent postgresql update, the postmaster failed to start because of this: | PANIC: The database cluster was initialized with LC_CTYPE | 'nl_NL@euro.UTF-8', which is...
9
by: Christian Wetzig | last post by:
hi, i have a table with test_field of type "TEXT". when i do: select test_field from test where id=1; the connection (with psql) hangs and no output is received, so i have to kill psql. ...
1
by: Eric | last post by:
Hi, I would like to know if a daemon exist to intercept Oracle queries and translate to postgresql query... I have a windows app (AccPac) that connect to an Oracle server via ODBC. I would...
2
by: Zlatko Matić | last post by:
Hello. I have the following problem with MS Access/PostgreSQL combination: There is a form in Access that has an unbound text box, used for entering a commentary of a batch of records. There is a...
8
by: bill.postgresql-users | last post by:
I installed 7.4 from the FreeBSD ports collection (I'm running 4.9-RELEASE). Did nothing special, just make && make install and all was well. I now have updated my ports collection via cvsup and...
5
by: Silvio Matthes | last post by:
Hello, I'm new to the list and did not find a suitable answer to my question so here it is: I try to select the rows of a table where the content of a varchar-column is empty ('') and...
1
by: DEHAINSALA Hondjack | last post by:
Hi ! sorry for my english ! I am french :-) I want to test postgreSQL v8 native Windows! Where i can get a version which allows more than 64 characters (NAMEDATALEN ~=128) to the name of tables...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.