Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Oracle ODBC Configuration From VB5

Posted on 1998-07-24
3
Medium Priority
?
699 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 300 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
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 how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 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