Solved

Oracle ODBC Configuration From VB5

Posted on 1998-07-24
3
672 Views
Last Modified: 2008-02-01
HELP!,

I am trying to automatically configure the Oracle ODBC data source from Visual Basic5.  I can set up a basic data source but cannot find the syntax required to load the SQl*Net Connect String.  I am currently using the following code
'Decalrations Used to Generate EUP DSN
Private Const ODBC_ADD_DSN = 1 ' Add data source
Private Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Private Const ODBC_REMOVE_DSN = 3 ' Remove data source
Private Const vbAPINull As Long = 0& ' NULL Pointer
#If Win32 Then
    Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
    (ByVal hwndParent As Long, ByVal fRequest As Long, _
     ByVal lpszDriver As String, ByVal lpszAttributes As String) _
     As Long
#Else
     Private Declare Function SQLConfigDataSource Lib "ODBCINST.DLL" _
     (ByVal hwndParent As Integer, ByVal fRequest As Integer, ByVal _
     lpszDriver As String, ByVal lpszAttributes As String) As Integer
#End If

    #If Win32 Then
        Dim intRet As Long
    #Else
        Dim intRet As Integer
    #End If
    Dim strDriver As String
    Dim strAttributes As String

   strDriver = "Oracle73 Ver 2.5"
    strAttributes = "SQL*Net Connect String=EUP" & Chr$(0)
    strAttributes = strAttributes & "DESCRIPTION=Europa Connection (EUP)" & Chr$(0)
    strAttributes = strAttributes & "DSN=EUP" & Chr$(0)
   
    intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, _
             strDriver, strAttributes)
0
Comment
Question by:WHITER
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1080796
Try this, it works on my computer

Public Sub CreateDSN()

   Dim intRet        As Long
   Dim strDriver     As String
   Dim strAttributes As String
   
   strDriver = "Oracle73 Ver 2.5"
   strAttributes = "Server=EUP" & Chr$(0)
   strAttributes = strAttributes & "DESCRIPTION=Europa Connection (EUP)" & Chr$(0)
   strAttributes = strAttributes & "DSN=EUP" & Chr$(0)
   
   intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver, strAttributes)

End Sub



0
 

Author Comment

by:WHITER
ID: 1080797
I Thought I'd already tried this........Well done it worked fine.

Thanks for your help.

0
 
LVL 14

Expert Comment

by:waty
ID: 1080798
You know, you could also use the following code and it works too, but without any API

Public Sub CreateDSN(sDSN As String)

   Dim nRet                As Long
   Dim sDriver             As String
   Dim sAttributes         As String
   
   
   strDriver = "Oracle73 Ver 2.5"
   strAttributes = "Server=EUP" & Chr$(0)
   strAttributes = strAttributes & "DESCRIPTION=Europa Connection (EUP)" & Chr$(0)
   strAttributes = strAttributes & "DSN=EUP" & Chr$(0)
   
   DBEngine.RegisterDatabase sDSN, strDriver, True, strAttributes
   
End Sub

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to recover a database from a user managed backup

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now