How can I Register a DSName In the System DSN Of ODBC ?

   I want to Register a Dsn Name for the ODBC in System DSN,through Visual Basic Code.  I'am able to register in User DSN through V.B Code, but i'am not able to register in System DSN through VB Code.

   This i want to do, because i'am developing an intranet based application with SQL Server 6.5 as the backend using Active X Controls.

   So after registering the OCX Controls in the Server, suppose if i'am accessing the file which is in the server.  The application is not loaded in IE browser, this is because it looks for the Local System DSN, which i have not configured.
If i'am configuring the System  DSN in the local machine, i'am able to access the application throught IE.  But it should be such that without configuring in the client's 32 bit odbc, i should able to access the application..

   This is possible only if i write to configure through the VB Code itself, and before registering the ocx control in the server.



pottiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pottiAuthor Commented:
Just help me
chris_aCommented:
I Have to do this soon in a new project at work, but my initial look leads me to think that HKLM\Software\ODBC\ODBC.INI\etc... is the place to go.

But as I will be doing this soon, hope you don't mind me observing the answers you get

Chris
pottiAuthor Commented:
Edited text of question.
Maximize Customer Retention with Superior Service

The IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more to help build customer satisfaction and retention.

pottiAuthor Commented:
Edited text of question.
chris_aCommented:
If you are doing it like this I think you do not need a dsn, I remember at an ms seminar they showed opening a recordset by setting the provider to something with http in it, I kind of ignored it as I tought it unlikely to work.
eyvind081997Commented:
Try This:

Option Explicit


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 ODBC_ADD_SYS_DSN = 4    ' Add a new system data source.

'ODBC_CONFIG_SYS_DSN: Modify an existing system data source.

'ODBC_REMOVE_SYS_DSN: Remove an existing system data source

Private Const vbAPINull As Long = 0&  ' NULL Pointer
       
       
       
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



Public Function AddODBCDSN()

    Dim strDriver As String
    Dim strAttributes As String
    Dim intRet As Long
     
    'since i do not have SQL Server installed....
    strDriver = "Microsoft Access Driver (*.mdb)"      'Set the attributes delimited by null.
    'See driver documentation for a complete
    'list of supported attributes.
     
    'You should use this
    'strDriver = "SQL Server"
    strAttributes = "SERVER=SomeServer" & Chr$(0)
    strAttributes = strAttributes & "DESCRIPTION=Test DSN" & Chr$(0)
    strAttributes = strAttributes & "DSN=DSN_TEMP" & Chr$(0)
    strAttributes = strAttributes & "DATABASE=c:\test.mdb" & Chr$(0)
    'strAttributes = strAttributes & "UID=" & Chr$(0)
    'strAttributes = strAttributes & "PWD=" & Chr$(0)
       
    'To show dialog, use Form1.Hwnd instead of vbAPINull.
    intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, strDriver, strAttributes)
    If intRet Then
        MsgBox "DSN Created"
    Else
        MsgBox "Create Failed"
     
    End If
End Function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pottiAuthor Commented:
After Executing The code, The windows is Shutdown saying that it Has performed an Illegal operation, but the DSN is created. I dont know the reason for the shutdown.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.