Re: How To Connect PostgreSQL thru VB without DSN

From: "Campbell, Greg" <greg(dot)campbell(at)us(dot)michelin(dot)com>
To: pragadheeswaran gopalakrishnan <pragadheeswaran(at)gmail(dot)com>, "Pgsql-Odbc (E-mail)" <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: How To Connect PostgreSQL thru VB without DSN
Date: 2006-03-20 14:55:40
Message-ID: 441EC26C.1020309@us.michelin.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

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.

Attachment Content-Type Size
greg.campbell.vcf text/x-vcard 252 bytes

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Dave Page 2006-03-20 15:19:31 Future versions of psqlODBC
Previous Message Raymond O'Donnell 2006-03-20 12:01:29 Re: Tutorial