OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Hugh Brown (hbrownASKARI.COM)
Date: Mon Jun 03 2002 - 09:15:52 CDT

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    You mean you want to programmatically populate a system DSN? I just run VB
    script like this:

    >>>
    '''HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\{DSN}
    '''Database = string name
    '''Driver = SQLSRV32.DLL
    '''Server = server name
    '''Description = ""

    const RegLocation = "HKLM\SOFTWARE\ODBC\ODBC.INI\"

    '
    ' Create a DSN for a SQL Server driver on a server and database
    '
    Sub CreateDSN (database, serverName)
            Dim DSN
            Dim WSHShell, base
            Set WSHShell = WScript.CreateObject("WScript.Shell")

            DSN = database + "-" + serverName

            base = RegLocation & DSN & "\"

            '' Create the key
            WSHShell.RegWrite base, ""

            '' Create the values
            '' Note that values do not end with "\" and keys do
            WSHShell.RegWrite base & "Database", database
            WSHShell.RegWrite base & "Server", serverName
            WSHShell.RegWrite base & "Description", "No description"
            WSHShell.RegWrite base & "Driver", "SQLSRV32.DLL"

            WSHShell.RegWrite base & "UseProcForPrepare", "Yes"
            WSHShell.RegWrite base & "OEMTOANSI", "Yes"
            WSHShell.RegWrite base & "Trusted_Connection", ""

            '' Add to the list of registered ODBC sources
            '' (Control Panel will not display it without this)
            WSHShell.RegWrite RegLocation & "ODBC Data Sources\" & DSN, "SQL Server"
            Set WSHShell = Nothing
    End Sub

    Sub DeleteDSN (DSN)
            Dim WSHShell, base
            Set WSHShell = WScript.CreateObject("WScript.Shell")

            base = RegLocation & DSN & "\"
            WSHShell.RegDelete base

            WSHShell.RegDelete RegLocation & "ODBC Data Sources\" & DSN
    End Sub
    <<<

    Then I make calls to associate a server and DB to a DSN like this:
    >>>
    CreateDSN "RB60DEV", "NTFS5"
    CreateDSN "RW60DEV", "NTFS5"
    <<<

    -----Original Message-----
    From: Blesson Paul [mailto:blessonpaulSOFTHOME.NET]
    Sent: Monday, June 03, 2002 2:37 AM
    To: DCOMDISCUSS.MICROSOFT.COM
    Subject: control to populate Data Sources

    Hi all
                    Is there any control in VC++ which can populate all the data
    sources in
    the SYSTEM DSN.

    regards
    Blesson Paul

    ----------------------------------------------------------------
    Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
    contains important info. Save time, search the archives at
    http://discuss.microsoft.com/archives/index.html .
    To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM