Re: ODBC Example with VB5? - Mailing list pgsql-interfaces

From Robert Rothe
Subject Re: ODBC Example with VB5?
Date
Msg-id 399C8808.87429E7E@mindspring.com
Whole thread Raw
In response to ODBC Example with VB5?  (Robert Rothe <rrothe@mindspring.com>)
List pgsql-interfaces
Well, it appears that updating the MDAC was a big part of the problem.  Thanks
to everyone who provided suggestions.

I did get everything to work under VB5.  For those interested, here is the
simple code used to test.  In VB, create one form with one list box "List1".
The following code goes into the form's load event.   There is no need to setup
a DSN using this method, although you can by specifying "DSN","USER","PWD" on
the conn1.open line.


Private Sub Form_Load()

Dim conn1 As New ADODB.Connection
Dim cmd1 As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim AccessConnect As String

AccessConnect =
"driver={PostgreSQL};server=192.168.1.59;database=testdata;uid=youruser;pwd=;"
conn1.ConnectionString = AccessConnect
conn1.Open
cmd1.ActiveConnection = conn1cmd1.CommandText = "Select * from users order by userid"Set rs = cmd1.Execute

While Not rs.EOF
   ' Null fields cause this to crash and burn, so use some logic...
   List1.AddItem rs("userid") + rs("lastn")   rs.MoveNext
Wend

'If you have unique keys, this will obviously only work once

cmd1.CommandText = "insert into users (userid,password,lastn) values
('xxxxxxx1','xxxxxxx2','Lastxxx')"
cmd1.Execute


End Sub


_~_~_~_~_~__~~__~_~~__~_~_~


Sean Alphonse wrote:

> Hello.
> I have worked with VB6 and Postgresql. One of the problems that I ran into
> was with me having to install MDAC 2.5 and another problem was with
> correctly configuring the pg_hba.conf file to allow remote machines to
> connect to PostgreSQL. Have you looked at these options?
>
> Sean.
>
> -----Original Message-----
> From: pgsql-interfaces-owner@hub.org
> [mailto:pgsql-interfaces-owner@hub.org]On Behalf Of Robert Rothe
> Sent: Thursday, August 17, 2000 8:34 AM
> To: Ashley Clark
> Cc: pgsql-interfaces@postgresql.org
> Subject: Re: [INTERFACES] ODBC Example with VB5?
>
> I've verified the ODBC configuration options.  I've tried a variety of
> combinations -- each of them with R/O off in both the Driver and
> Advanced dialogs.
>
> I suspect my problem is more with VB than with Postgres.  Although I did
> have a similiar issue when trying to access PG databases via Access.
>
> Do you, or anyone else, have a few lines of code that maybe do this:
>
> a) Open database
> b) Read a record set via select into a ListBox
> c) Add a record
>
> That would be all I need.  With this working code, I could debug any
> ODBC issues better.
>
> Thanks,
> Rob
>
> Ashley Clark wrote:
> >
> > * Robert Rothe in "[INTERFACES] ODBC Example with VB5?" dated
> > * 2000/08/16 21:14 wrote:
> >
> > > Can anyone point me to an example of using the postgresql ODBC driver
> > > with Visual Basic 5.0?  I've tried several suggestions from this
> > > list, but still experience read-only errors.  I'm not even sure I'm
> > > using the DAO/RDO/R2D2 calling methods.
> >
> > Have you configured your ODBC Data Source correctly?
> >
> > Under Driver Options, uncheck ReadOnly.
> > Under Advanced Options, uncheck ReadOnly.
> >
> > > I'm currently using the 6.50 version of the ODBC driver.
> >
> > Good luck, it should work out ok.
> >
> > --
> > shaky caller
> >
> >   ------------------------------------------------------------------------
> >    Part 1.2Type: application/pgp-signature



pgsql-interfaces by date:

Previous
From: Josh Berkus
Date:
Subject: Re: ODBC Example with VB5?
Next
From: "Jim O'Rourke"
Date:
Subject: /tmp/.s.PGSQL.${PGPORT}