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: Niall Litchfield <n-litchfield_at_audit-commission.gov.uk>
Date: Tue, 28 Mar 2000 15:27:11 +0100
Message-ID: <8bqfg1$i2p$1@soap.pipex.net>


Hi

I haven't actually done it this way. however as I understand your code you will end up (if successful) with a new ODBC DSN which the logged in user can then use in their applications (for example Excel and Access) is this actually what you want? I nearly always prefer to hide the data source attributes in my app. whadya mean I don't trust my users.. <g> If this is what you want then I expect that it is the server name parameter that is wrong. these parameters seem to change their values depending on what provider you are using.

--
Niall Litchfield
Oracle DBA
Audit Commission UK
<cibermike_at_my-deja.com> wrote in message news:8bo544$cn7$1_at_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 Tue Mar 28 2000 - 08:27:11 CST

Original text of this message

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