From: | Robert Rothe <rrothe(at)mindspring(dot)com> |
---|---|
To: | Sean Alphonse <salphonse1(at)home(dot)com>, pgint <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | Re: ODBC Example with VB5? |
Date: | 2000-08-18 00:49:12 |
Message-ID: | 399C8808.87429E7E@mindspring.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 = conn1
cmd1.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(at)hub(dot)org
> [mailto:pgsql-interfaces-owner(at)hub(dot)org]On Behalf Of Robert Rothe
> Sent: Thursday, August 17, 2000 8:34 AM
> To: Ashley Clark
> Cc: pgsql-interfaces(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Minas Abrahamian | 2000-08-18 10:41:40 | Where is new pgsql ODBC driver ? |
Previous Message | FredDvorak | 2000-08-17 20:00:37 | MS Access + Postgres |