473,699 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# .NET ===> postgreSQL

2 New Member
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?


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 22184
michaelb
534 Recognized Expert Contributor
You probably want to look at the Postgres` Client Interfaces, especially libpq - C library and this Example Program
Mar 11 '07 #2
knowledgeseeker
3 New Member
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?


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 New Member
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?


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 Recognized Expert New Member
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
1664
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 PostgreSQL link resource in /usr/share/pear/DB/pgsql.php on line 449 Any idea. Thanks
2
3599
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. When I have Unicode strings in Python and store it in a PostgreSQL Unicode database, will the data automatically be correctly encoded? Or do I need to specify the UTF-8 client encoding on the database connection somehow? I'm using the...
2
1897
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 all the ones I've looked at so far have major drawbacks. What I'm looking for in an object-relational wrapper layer is:
12
6189
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 not recognized by setlocale(). | It looks like you need to initdb. Now I know nl_NL@euro.UTF-8 is an incorrect locale, I fixed that some
9
2267
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. this occurs, at first sight, if length(test_field)>32748.
1
2363
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 like to replace the Oracle server with a postgresql. Accpac support only Oracle, DB2, MS-SQL and pervasive. So, something capable of interpreting...
2
3890
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 DAO Append Query that has a parameter that is passed from the text box using parameter of DAO QueryDef object. I adjusted B7 parameter (Text as LongVarchar) in connection string (ODBC driver) to 1, so that Access links PostgreSQL Text fields as...
8
1579
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 see that the 7.4.1 port is available. So now I have several, very specific needs: 1) having now done some development in 7.4, I've decided I need to be able to exceed the default limit of 16 arguments for plpgsql functions 2) I would like to...
5
2348
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 PostgresQL is doing a seqscan. I've tried this on a PostgresQL-Serverversion 7.3.4 and 8.0 beta1.
1
3009
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 and columns ? I generate automaticly tables and the length of some of these tables is > to 64.
0
8706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8631
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9055
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8945
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8902
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7787
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4392
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4641
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.