Solved

Oracle ODBC Configuration From VB5

Posted on 1998-07-24
3
683 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

688 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