Solved

Oracle ODBC Configuration From VB5

Posted on 1998-07-24
3
665 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

757 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

21 Experts available now in Live!

Get 1:1 Help Now