Solved

Connection to a Postgres Database with visual Basic

Posted on 2006-11-21
6
651 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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