Cannot get connection strings from machine.config file

Last post 11-18-2008 1:49 PM by haz33. 1 replies.

Sort Posts:

  • Cannot get connection strings from machine.config file

    11-18-2008, 12:45 PM
    • Member
      5 point Member
    • haz33
    • Member since 02-13-2008, 11:15 AM
    • Posts 28

    Hi, I am attempting to load connection strings from my server's machine.config file. On our old server, this worked just fine. We just installed SQL Server, IIS, and Visual Studio on a brand new server. I created a project and, using the same code, made reference to a connection string that should be retrieved from the machine.config file. Unfortunately, I'm getting an "Object variable or With block variable not set" on the line that references the connection string's name.

    When I searched my C:\WINDOWS\Microsoft.NET directory, I found a machine.config in each of these locations:

    \Framework\v1.1.4322\CONFIG 

    \Framework\v2.0.50727\CONFIG

    \Framework64\v2.0.50727\CONFIG

     

    I added the connection string to the two version 2.0.50727 machine.config files. I didn't do anything to the version 1.1.4322 file because there were no tags for connection strings in that file. This is a 32-bit project so I'd think I'd want to reference the middle one. What am I doing wrong? Why won't my project see the connection string in the file? Thanks!

  • Re: Cannot get connection strings from machine.config file

    11-18-2008, 1:49 PM
    Answer
    • Member
      5 point Member
    • haz33
    • Member since 02-13-2008, 11:15 AM
    • Posts 28

    Resolved the problem. I had created another website in IIS and I had deleted the Default Web Site. Not a good idea. Anyhow, to restore it, follow this procedure:

    http://geekswithblogs.net/lorint/archive/2005/12/09/62737.aspx

    That fixed my machine.config problem as well. Incidentally, my machine is looking at the machine.config file in the Framework64 directory.

Page 1 of 1 (2 items)