Solved

Connection to a Postgres Database with visual Basic

Posted on 2006-11-21
6
649 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

808 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