locked
cannot read connection string. RRS feed

  • Question

  • Hey folks,

    This should be a quick one.  I created a web application with web controls n stuff in it... nothing complex (im only recently learning). and I need to connect to an Sql database for data retrival. At the moment I have my connection string in the code behind (which apparently in not secure, could also use some explenation as why this isn't secure) and it work fine when I deploy the app to the website (copying the ap's dll and the controls). So I transer my connection string to the web.config.. and read it via ConfigurationManager..  but when I deploy it brings up a NullReferenceException... meaning, I cannot get the string.

    My guess was that I needed to transfer the web.config file to the website.. but that ain't working either (or at least not by copying the file to the bin folder along with the dll)... So how do how do I do it??? I know the code is fine.. it has to do with the file itslef. I read somewhere about having a web.dll.config but  I cannot fin it in my project folder.

    Any help would be appreciated

    Cheers


    Pilsen

    Tuesday, November 13, 2012 5:40 AM

Answers

All replies

  • do not copy the web.config file too the bin folder. it must be in the root path 
    Tuesday, November 13, 2012 7:17 AM
  • How did you write the connection string.

    Please follow this tutorial:

    http://msdn.microsoft.com/en-us/library/ms178411(v=vs.80).aspx

     

    Noam B.



    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you...

    • Marked as answer by pilsen86 Tuesday, November 13, 2012 10:00 PM
    Tuesday, November 13, 2012 1:49 PM
  • Thanks Noam, 

    That worked like a charm... I just needed to copy the connection string to the web.config file in my site an use WebConfigurationManager. 

    Thanks a lot


    Pilsen

    Tuesday, November 13, 2012 10:04 PM