Solved

Connection to a Postgres Database with visual Basic

Posted on 2006-11-21
6
645 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

743 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