How to set connectionStrings in Web.config to reference exteral xml file?

Last post 01-29-2007 1:36 PM by david@davidlwalker.com. 3 replies.

Sort Posts:

  • How to set connectionStrings in Web.config to reference exteral xml file?

    01-25-2007, 6:31 PM
    • Loading...
    • Kiril2006
    • Joined on 12-27-2006, 8:27 PM
    • Posts 130

    Hello,

    Does anyone know how to reference XML files thats not in my realative directory? I need to place my connectinString in a XML file thats located outside of my local directory. I keep getting this messages "the configSource atribute must be a relative physical path..."

    Thank in advance..

  • Re: How to set connectionStrings in Web.config to reference exteral xml file?

    01-25-2007, 11:04 PM

    Hi,

    At this time it is not possible for security reasons. See this post on MSDN for more details:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=318234&SiteID=1

    It looks as though IIS7's updated configuration capabilities will help:

    http://shaikariv-ms.spaces.live.com/blog/cns!1E15C67CC48202AB!114.entry?_c11_blogpart_blogpart=blogview&_c=blogpart

    Hope this helps.

    Sincerely,
    David Walker

    Code On!

    David Walker, MCP, MCAD, MCSD, MVP - ASP/ASP.NET
    www.davidlwalker.com

    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: How to set connectionStrings in Web.config to reference exteral xml file?

    01-26-2007, 11:16 AM
    • Loading...
    • Kiril2006
    • Joined on 12-27-2006, 8:27 PM
    • Posts 130

    Hi Dave,

    Do you know how to set the typed data sets to reference appSettings atribute in web.config instead connectionString which is by default. The reason is because i have created all of my typed datasets using connectionString atrubute but it happened that i need to use appSettings instead because thats the only way i can access extrernal xml file. This file contains our connection settings and therefore all application should be using it..

    Thanks ,

    Kiril

  • Re: How to set connectionStrings in Web.config to reference exteral xml file?

    01-29-2007, 1:36 PM

    Hi Kiril,

    If I fully understand what you are trying to do, this thread on MSDN Forums should contain your answer:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1054316&SiteID=1

    In summary:

     <appSettings>
    <add key ="connectionSource" value="Data Source=127.0.0.1,1544;Network Library=DBMSSOCN;Initial Catalog=pinnacleCMS;User Id=*****;Password=*****;"/>
    </appSettings>

    You would then read it back into your application like so:

    using

    System.Configuration;

    myString = ConfigurationSettings.AppSettings["ConnectionSource"];

    System.Data.OleDb.OleDbConnection myConnection = new System.Data.OleDb.OleDbConnection(myString);
    myTableAdapter.Connection = myConnection;

    There's much more detail on the MSDN forums.

    Hope this helps.

    Sincerely,

    David Walker

    Code On!

    David Walker, MCP, MCAD, MCSD, MVP - ASP/ASP.NET
    www.davidlwalker.com

    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter