Re: Oracle ODBC connection and VB4

From: Joel Cornell <joelc_at_kodak.com>
Date: 1997/05/15
Message-ID: <337b509d.3713949647_at_newsserver.rdcs.kodak.com>#1/1


On Tue, 13 May 1997 21:25:45 -0400, "Robert T. Bunch" <bunchr_at_mnsinc.com> wrote:

>Steve Thompson wrote:
>>
>> Mark McCubbin wrote:
>> >
>> > I need my VB4 application to "talk" to the Oracle Local Database that
>> > resides on my desktop PC. When I try to open the database from my VB4
>> > app, I get the error message "Couldn't find installable ISAM."
>> >
>> > To setup the data source I double-clicked the ODBC icon in Control
>> > Panel, clicked the Add button, chose "Oracle ODBC Driver for Rdb," and
>> > keyed in "Local Database" for data source name.
>> >
>> > The connect code I use in my VB code is
>> >
>> > sConnect = "C:\WINDOWS\SYSTEM\ODBC32.DLL;UID=SCOTT;PWD=TIGER"
>> >
>> > ' Get ISAM error message on next line...
>> > Set dbPersonInfo = OpenDatabase("Local Database", False, False,
>> > sConnect)
>> >
>> > If you have any advice, I would appreciate your assistance. Thank you.
>> >
>> > Mark
>>
>> Mark, Your connect string is wrong. It should look like
>> sConnect = "ODBC;DSN=yourdsn;UID=SCOTT;PWD=TIGER"
>>
>> where "yourdsn" is a Data Source Name you have set up in the ODBC
>> administrator. Since it appears you are using 32-bit windows, This would
>> be in the Control Panel under ODBC. You'll have to set the connect
>> string in the DSN to the name of your database instance or try "2:" for
>> the default one.
>
>I'm kinda having the same problem... I'm using VB Pro 4/32, and have
>managed to make a connection to PO7/95 with:
>
> Data1.Connect = "ODBC;DSN=beq-local;UID=scott;PWD=tiger;"
>
>Verified it with 'select username from v$session'. Problem is, I can't
>seem to find any GOOD documentation on going any further to even do a
>simple SELECT statement! If I can manage to do a simple select and dump
>it into say, a TEXT control, I'm good to go...
>
>Any help would be greatly appreciated!

Global gblConn As RDO.rdoConnection

  Set gblConn =
rdoEnvironments(0).OpenConnection("",rdDriverComplete,True, "DSN=yourdsn;UID=scott;PWD=tiger;")

  Dim sSQL1 As String
  Dim Rs As RDO.rdoResultset

  sSQL = "select f0,f1,f2 from table"
  Set Rs = gblConn.OpenResultset(SQL1, rdOpenStatic, rdConcurReadOnly)   If not Rs.EOF Then

    Text0 = Rs!f0      'on2 way to reference a column in resultset
    Text1 = Rs("f1")  'another way you can reference it
    Text2 = Rs(2)      'yet another way

  End If
  Rs.Close

'This is a typical application - looping through the items in a 'resultset - see how using With makes things neater

  sSQL = "select f0,f1,f2 from table"
  Set Rs = gblConn.OpenResultset(SQL1, rdOpenStatic, rdConcurReadOnly)   With Rs
    Do While Not .EOF

      Debug.Print !f0,!f1,!f2
      .MoveNext

    Loop
  End With
  Rs.Close

  gblConn.Close

Note: I'm not advocating opening and closing the database connection immediately before and after a query. I'm just reminding you that these steps need to occur somewhere Also notice that I'm not using bound database controls. In general you want to stay away from them. Feel free to debate me or flame me on this (I've been through it plenty of times at work and usually they concede that it doesn't gain you anything in the long run after stubbornly trying it anyway).

Hope this helps a little Received on Thu May 15 1997 - 00:00:00 CEST

Original text of this message