If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > parameterized servername in connection string

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-06-10, 07:50
hbkelkar hbkelkar is offline
Registered User
 
Join Date: Jan 2007
Posts: 9
parameterized servername in connection string

Hi all,
I have just started to explore the wonders of PostgreSql. and my coding environment is VB.NET
I am experiencing problem in connection to the database. I need to parameterize the connection string based on the server where the pgsql is installed.
like constring = "Server=<machine_name_as_parm>;
other parameter values can work well.
But if change the server parameter to a different computer name, then it throw an error.
"Unable to read data from transport connection:"

Even the hardcoaded ip address also failed.
my sample con string looks like this..
strString = String.Format("Host={0};Port={1};User Id={2};Password={3};Database={4};", "172.201.0.39", "5432", "pguser", "pgpwd", "sampledb")

(My intension is, if in any case the database migrated to a different machine, i can pass the server_machine_name/ip thro login form, and use the same as a parameter to connect to postgres in that machine over network)

Can anybody help in this regard?

anticipating helpful responses...

regards:
Reply With Quote
  #2 (permalink)  
Old 04-06-10, 17:19
vibhor.aim vibhor.aim is offline
Registered User
 
Join Date: Apr 2010
Posts: 16
Following link would be useful for you:
Postgre SQL Connection String Samples - ConnectionStrings.com
Reply With Quote
  #3 (permalink)  
Old 04-07-10, 00:53
hbkelkar hbkelkar is offline
Registered User
 
Join Date: Jan 2007
Posts: 9
Hi Vibhor,
Thanks for the link.
I did gone through the connectionstrings.com and as i am using npgsql i have used the exact format for connection string. But when i use <localhost> as the server name connection works well but if i change it to the machine ip address it throws an error.
Am is missing something or there is other way around.

hoping to get a resolution for my problem.
Reply With Quote
  #4 (permalink)  
Old 04-07-10, 11:13
futurity futurity is offline
Registered User
 
Join Date: May 2008
Posts: 270
Assuming that your script is successfully attempting to connect, then check your listen_addresses setting in postgresql.conf.
Reply With Quote
  #5 (permalink)  
Old 04-07-10, 16:30
vibhor.aim vibhor.aim is offline
Registered User
 
Join Date: Apr 2010
Posts: 16
Futurity is right, please check the listen_address parameter in postgresql.conf. It seems, port is not binded with IP Addess.
Reply With Quote
  #6 (permalink)  
Old 04-10-10, 11:24
hbkelkar hbkelkar is offline
Registered User
 
Join Date: Jan 2007
Posts: 9
:Futurity, Vibhor
Thanks for your information, will definitely go thro the links and come back with some answer..
thanks
Reply With Quote
Reply

Tags
connection servername, postgres

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On