Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Automate registering a DSN

Automate registering a DSN

Scheduled Pinned Locked Moved Database
databasesql-serversysadminwindows-adminquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Robby
    wrote on last edited by
    #1

    I have been researching for ways to automatically create a SQL Server DSN on a local machine for a application and include it in the installation of the client to eliminate a user attempting to set the DSN themselves. I have found a couple of examples inserting information into the registry, but I do not want to do it this way. I found a vague article on the use of DBEngine.RegisterDatabase function, but am unable to find details. Has anyone performed this in the past? :~

    R A M 3 Replies Last reply
    0
    • R Robby

      I have been researching for ways to automatically create a SQL Server DSN on a local machine for a application and include it in the installation of the client to eliminate a user attempting to set the DSN themselves. I have found a couple of examples inserting information into the registry, but I do not want to do it this way. I found a vague article on the use of DBEngine.RegisterDatabase function, but am unable to find details. Has anyone performed this in the past? :~

      R Offline
      R Offline
      Rein Hillmann
      wrote on last edited by
      #2

      Any reason why you don't want to go with the registry? Microsoft even recommends it: HOWTO: Programmatically Create a DSN for SQL Server with VB http://support.microsoft.com/default.aspx?scid=KB;en-us;q184608

      1 Reply Last reply
      0
      • R Robby

        I have been researching for ways to automatically create a SQL Server DSN on a local machine for a application and include it in the installation of the client to eliminate a user attempting to set the DSN themselves. I have found a couple of examples inserting information into the registry, but I do not want to do it this way. I found a vague article on the use of DBEngine.RegisterDatabase function, but am unable to find details. Has anyone performed this in the past? :~

        A Offline
        A Offline
        Alexander Kojevnikov
        wrote on last edited by
        #3

        check out the documentation on SQLConfigDataSource function from odbccp32.dll... Alexandre Kojevnikov MCP (SQL2K) Leuven, Belgium

        1 Reply Last reply
        0
        • R Robby

          I have been researching for ways to automatically create a SQL Server DSN on a local machine for a application and include it in the installation of the client to eliminate a user attempting to set the DSN themselves. I have found a couple of examples inserting information into the registry, but I do not want to do it this way. I found a vague article on the use of DBEngine.RegisterDatabase function, but am unable to find details. Has anyone performed this in the past? :~

          M Offline
          M Offline
          mwilliamson
          wrote on last edited by
          #4

          Heres some code I have been using: // Create ODBC Datasource //////////////////////////////////////////////// char szConfig[256] = ""; sprintf(szConfig, "DSN=MyDSN\0Description=My Description\0DBQ=%s\0UID=Admin\0\0", m_sDatabasePath); SQLConfigDataSource(NULL, ODBC_ADD_DSN, "Microsoft Access Driver (*.mdb)\0", szConfig ); ////////////////////////////////////////////////////////////////////////// You might need to modify it slightly for SQL Server. I just run this in InitInstace, there is no need to check if it exists since it will just be overwritten if it does.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups