Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Create DSN Programmatically for Oracle 7.3

Re: Create DSN Programmatically for Oracle 7.3

From: <cibermike_at_my-deja.com>
Date: Mon, 27 Mar 2000 17:18:13 GMT
Message-ID: <8bo544$cn7$1@nnrp1.deja.com>


Thanks Niall,

Your solution may be the simplest. I'll have to test it to see if I have any problems with the Network/gateways.

I would prefer a DSN-less connection if possible. We have some issues with various gateways and TCP/IP.

What I was looking for is the correct attributes to make this work: (The reason is that I'm going to roll the app out to a large Nbr of PC's)

'Declares

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

'Private Const ODBC_ADD_SYS_DSN = 4 'constant for a system DSN

'I want a User DSN rather then system.

Private Const ODBC_ADD_DSN = 1 'constant for a user DSN

Public Function AddOracleDSN()

    Dim lngResult As Long
    Dim strAttribs As String

    strAttribs = "DSN=2WinFast" & Chr(0) & "UID=" & Chr(0) & "PWD=" & Chr(0) & "CONNECTSTRING=oratst1" & Chr(0) & Chr(0)

' strAttribs = "DSN=2WinFast" & Chr(0) & "UID=" & Chr(0) & "PWD=" & Chr
(0) & "SERVER=oratst1" & Chr(0) & Chr(0)

    lngResult = SQLConfigDataSource(0, ODBC_ADD_DSN, "Microsoft ODBC Driver for Oracle", strAttribs)
' if result = 1 then all is well

End Function

This runs but returns 0 and the DSN is not created. I haven't been able to determine the "correct" set of attributes to use. The only MSDN sample I could find is in C++. I don't really want to make a C++ DLL if I don't have to.
I could use the "Oracle73" driver, but I'm certain to find the MS driver installed, so I'm using that one right now.

'Note; it will work for a SQL Server DSN with:
Sub CreateDSNn()
  Dim result As Long
  Dim attribs As String

  attribs = "DSN=MyDSN" & Chr(0) & "SERVER=SampleDB" & Chr(0) & "DESCRIPTION=SQLConfig" & Chr(0) & "SERVER=SampleDB" & Chr(0) & "ADDRESS=MyServer" & Chr(0) & "DATABASE=pubs" & Chr(0) & Chr(0)

  result = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, "SQL Server", attribs)
  ' if result = 1 then all is well
End Sub

Any ideas on the correct attributes to use? Thanks for the help.

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Mon Mar 27 2000 - 11:18:13 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US