Solved

Connection to a Postgres Database with visual Basic

Posted on 2006-11-21
6
648 Views
Last Modified: 2013-11-25
Hello experts,

  I am wondering if anyone has a complete example code of how to connect to a Postgres database which is on a remote server in Visual Basic.  I am not a visual basic programmer (at all) but one of our programmers is.  However, he does not know how to connect to a database.    I am assuming he will need instructions on how to create an appropriate DSN in ODBC  if that is how VB'ers connect.

-G
0
Comment
Question by:gmanpert
6 Comments
 
LVL 10

Assisted Solution

by:Clif
Clif earned 50 total points
ID: 17989695
Look Here:

http://www.connectionstrings.com/

(PostgreSQL is there)
0
 

Author Comment

by:gmanpert
ID: 17989981
Hey that's great, but it looks as if it only covers how to build a connection string.  What I am looking for is a simple program which connects, retrieves some data, prints it, then disconnects.   If this were Perl I could send you such a beast in a few seconds.   There must be at least one VB coder out there who has done something like this before.

-g
0
 
LVL 1

Assisted Solution

by:s2000lover
s2000lover earned 50 total points
ID: 17993649
http://wwwmaster.postgresql.org/download/mirrors-ftp?file=odbc%2Fversions%2Fmsi%2Fpsqlodbc-08_02_0200.zip

This site is the ODBC driver that you will need to connect to the database. Once that is installed, just add a adobc connection to your form and use that driver to connect to the database.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 30

Assisted Solution

by:nmcdermaid
nmcdermaid earned 100 total points
ID: 18005150
That connection string posted is for use in the ADO programming library.

Once you have successfully created an ADO connection, there are zillions of examples on the web of how to do data manipulation in ADO.


To be totally honest if your VB programmer doesn't know how to connect to a database I'd be a little worried.
0
 
LVL 4

Accepted Solution

by:
seshu123 earned 300 total points
ID: 18005764
Hai,
    The connection string is as follows:
declare one variable strConnect, and write this in a procedure which is capable of taking the inputs like server, username, database, password which are used to prepare the connection to the postgre sql database.
create one variable of type connection string and assign the follwoing to that connection string variable. Then you made it.

      strConnect = "Driver={PostgreSQL};Server=" & strServer & _
                   ";port=5432;Database=" & strDatabase & _
                   ";Uid=" & strUserID & _
                   ";Pwd=" & strPassword
    'strConnect = "PayrollDSN"
    ' connection properties
    With m_connData
        .ConnectionString = strConnect
        .ConnectionTimeout = 30
        .CursorLocation = adUseClient
        .Open
    End With


Seshu123
0
 
LVL 4

Assisted Solution

by:seshu123
seshu123 earned 300 total points
ID: 18005765
hai,
  I forgot one thing.  pls mention the ip-address of the system where your database is there.


Seshu123
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now