From: Campbell, Greg <greg.campbell@us.michelin.com>
To: pragadheeswaran gopalakrishnan <pragadheeswaran@gmail.com>
To: Pgsql-Odbc (E-mail) <pgsql-odbc@postgresql.org>
Subject: Re: How To Connect PostgreSQL thru VB without DSN
Date: Mon, 20 Mar 2006 09:55:40 -0500
Message-ID: <441EC26C.1020309@us.michelin.com> (raw)
In-Reply-To: <fc163d500603200311t2c06ffe6i@mail.gmail.com>
References: <fc163d500603180526s51e63230u@mail.gmail.com>
<441C8709.2080004@us.michelin.com>
<fc163d500603200311t2c06ffe6i@mail.gmail.com>
1. One thing at a time. Eliminate the section where you try to put data into the database. Does the
connection work. Do you get to the msgbox "Connection Message"?
2. Your pg_hba.conf host sections -- I hope you realize those are the addresses of your clients, so your
VB work station would have to have an I.P. of 200.200.200.something.
3. A normal PG problem would throw an error, which would show up as a message box, but VB would not crash
and close -- but your application will if it doesn't catch and handle errors. VB crashing indicates a more
gross error -- bad VB installation, missing References, code that's just wrong, etc.
4. The rsFriends seems to be missing a declaration and instantiation.
eg.
Dim rsFriends as ADODB.Recordset
Set rsFriends = new ADODB.Recordset
(Dim x as new Object -- is considered a somewhat sloppier form,
because it does not match the Set x= Nothing)
But as my first words indicate, don't worry about INSERTS or SELECTS until you are sure Connect will work.
5. Once you get the connect with the DSN, work on the DSN-less connect with the "Driver=..." string.
pragadheeswaran gopalakrishnan wrote:
>>4. Does your PostgreSQL server permit the username and password your are
>>trying to supply from your
>>location? Check pg_hba.conf settings.
>>
>>
>>
>
> Hi! Campbell, Thanks for replying,
>
> I will furnish some details for your kind notice.
>
> I am using VB to connect PostgreSQL database. It gets connected thru DSN
> based code.
>
> The following is a segment of my pg_hba.conf file
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> .
> .
> .
>
>
> # TYPE DATABASE USER CIDR-ADDRESS METHOD
>
> # IPv4 local connections:
> host all all 127.0.0.1/32 md5
> host all all 200.200.200.1 255.255.255.0
> md5
> # IPv6 local connections:
> host all all ::1/128 md5
> #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> When i run the code thru VB which is based on DSN leads to the following
> error
> "VB6.exe has generated errors and will be closed by Windows. You will need
> to restart
> the program."
>
> and VB itself gets closed after this error message
>
> my OS is WIN-2K
> my postgreSQL version is 8.1
>
>
> The code, which i used to connect pgsql is the following
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Dim cCon As New ADODB.Connection, rsFriends As New ADODB.Recordset
> Private Sub Form_Load()
> ConnectDB
> End Sub
> Private Sub ConnectDB()
> On Error GoTo EH
>
>
> cCon.ConnectionString = "DSN=pgsdsn;" & _
> "UID=steve;" & _
> "PWD=king;" & _
> "Database=mydb"
>
> cCon.Open
> MsgBox "O.K.", vbInformation, "Connection Message"
> With rsFriends
> .Open "SELECT * FROM Friends", cCon, adOpenKeyset,
> adLockPessimistic 'Here only the error is generated
> .AddNew
> .Fields![FriNam] = InputBox("Enter the Friend Name")
> .Fields![SrlNum] = Val(InputBox("Enter the Serial Number"))
> .Fields![DOB] = InputBox("Enter the Date of Birth")
> .Fields![PhNo] = InputBox("Enter the Phone No:")
> .Update
> End With
> If rsFriends.State = adStateOpen Then rsFriends.Close
> Set rsFriends = Nothing
> MsgBox "O.K.", vbInformation, "Recordset Message"
> Exit Sub
> Exit Sub
> EH:
> MsgBox Err.Description, vbCritical, "Error Message"
> End Sub
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
>
>
>
> The following, is the Error details written in LOG file under the LOG folder
> of POSTGRESQL
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> 2006-03-20 12:15:31 LOG: unexpected EOF on client connection
> 2006-03-20 12:15:37 LOG: could not receive data from client: No connection
> could be made because the target machine actively refused it.
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
> Many Thanks in advance.
Attachments:greg.campbell.vcf (text/x-vcard, 252B) download
begin:vcard
fn:Greg Campbell
n:Campbell;Greg
org:Michelin North America - US5 Lexington;ENG-ASE
email;internet:greg.campbell@us.michelin.com
title:ASE Systems Engineer
tel;work:803-951-5561/x75561
x-mozilla-html:FALSE
version:2.1
end:vcard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: greg.campbell@us.michelin.com, pragadheeswaran@gmail.com
Subject: Re: How To Connect PostgreSQL thru VB without DSN
In-Reply-To: <441EC26C.1020309@us.michelin.com>
References: <fc163d500603180526s51e63230u@mail.gmail.com> <441C8709.2080004@us.michelin.com> <fc163d500603200311t2c06ffe6i@mail.gmail.com> <441EC26C.1020309@us.michelin.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox