Configuration file read problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Enzer

    Configuration file read problem

    I need to use a configuration file to set the connection string for the ado
    data connector in my project, but I'm having trouble reading the config
    file.

    My config file contains the following:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuratio n>
    <appSettings> <add key="Connection String" value="server=l ocalhost;user
    id=root;passwor d=pw;database=a ceinventory;poo ling=false"/>
    </appSettings>
    </configuration>

    The file is named ACE_Inventory.c onfig where ACE_Inventory is the name of
    the project's exe file and is located in the project's bin folder.

    I'm using the following line to read the file:
    sInventoryConne ction =
    System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")

    Unfortunately, this does not read the config file.

    I'd sure appreciate any advice.

    Thanks, Steve Enzer


  • Marina

    #2
    Re: Configuration file read problem

    Try ACE_Inventory.e xe.config

    "Steve Enzer" <nospam@nospam. com> wrote in message
    news:uacExUtvFH A.460@TK2MSFTNG P15.phx.gbl...[color=blue]
    >I need to use a configuration file to set the connection string for the ado
    >data connector in my project, but I'm having trouble reading the config
    >file.
    >
    > My config file contains the following:
    >
    > <?xml version="1.0" encoding="utf-8" ?>
    > <configuratio n>
    > <appSettings> <add key="Connection String" value="server=l ocalhost;user
    > id=root;passwor d=pw;database=a ceinventory;poo ling=false"/>
    > </appSettings>
    > </configuration>
    >
    > The file is named ACE_Inventory.c onfig where ACE_Inventory is the name of
    > the project's exe file and is located in the project's bin folder.
    >
    > I'm using the following line to read the file:
    > sInventoryConne ction =
    > System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")
    >
    > Unfortunately, this does not read the config file.
    >
    > I'd sure appreciate any advice.
    >
    > Thanks, Steve Enzer
    >
    >[/color]


    Comment

    • Steve Enzer

      #3
      Re: Configuration file read problem

      I've tried that, as that is what the Microsoft documentation says to do.
      But as soon as I run the app in debug mode, Visual Studio immediately
      deletes the file.

      "Marina" <someone@nospam .com> wrote in message
      news:Oe%23rYYtv FHA.664@tk2msft ngp13.phx.gbl.. .[color=blue]
      > Try ACE_Inventory.e xe.config
      >
      > "Steve Enzer" <nospam@nospam. com> wrote in message
      > news:uacExUtvFH A.460@TK2MSFTNG P15.phx.gbl...[color=green]
      >>I need to use a configuration file to set the connection string for the
      >>ado data connector in my project, but I'm having trouble reading the
      >>config file.
      >>
      >> My config file contains the following:
      >>
      >> <?xml version="1.0" encoding="utf-8" ?>
      >> <configuratio n>
      >> <appSettings> <add key="Connection String" value="server=l ocalhost;user
      >> id=root;passwor d=pw;database=a ceinventory;poo ling=false"/>
      >> </appSettings>
      >> </configuration>
      >>
      >> The file is named ACE_Inventory.c onfig where ACE_Inventory is the name of
      >> the project's exe file and is located in the project's bin folder.
      >>
      >> I'm using the following line to read the file:
      >> sInventoryConne ction =
      >> System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")
      >>
      >> Unfortunately, this does not read the config file.
      >>
      >> I'd sure appreciate any advice.
      >>
      >> Thanks, Steve Enzer
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Phil G.

        #4
        Re: Configuration file read problem

        Steve,

        try this. Add a new item to your project and select the Application
        Configuration. Don't change the default name app.config. Now open this
        config file and copy/paste from your original into this new one.

        Now, when you build your project it will automatically create the
        project.exe.con fig file for you and place it in the bin folder!

        HTH, Phil

        "Steve Enzer" <nospam@nospam. com> wrote in message
        news:%23YhbP4tv FHA.1168@TK2MSF TNGP10.phx.gbl. ..[color=blue]
        > I've tried that, as that is what the Microsoft documentation says to do.
        > But as soon as I run the app in debug mode, Visual Studio immediately
        > deletes the file.
        >
        > "Marina" <someone@nospam .com> wrote in message
        > news:Oe%23rYYtv FHA.664@tk2msft ngp13.phx.gbl.. .[color=green]
        >> Try ACE_Inventory.e xe.config
        >>
        >> "Steve Enzer" <nospam@nospam. com> wrote in message
        >> news:uacExUtvFH A.460@TK2MSFTNG P15.phx.gbl...[color=darkred]
        >>>I need to use a configuration file to set the connection string for the
        >>>ado data connector in my project, but I'm having trouble reading the
        >>>config file.
        >>>
        >>> My config file contains the following:
        >>>
        >>> <?xml version="1.0" encoding="utf-8" ?>
        >>> <configuratio n>
        >>> <appSettings> <add key="Connection String" value="server=l ocalhost;user
        >>> id=root;passwor d=pw;database=a ceinventory;poo ling=false"/>
        >>> </appSettings>
        >>> </configuration>
        >>>
        >>> The file is named ACE_Inventory.c onfig where ACE_Inventory is the name
        >>> of the project's exe file and is located in the project's bin folder.
        >>>
        >>> I'm using the following line to read the file:
        >>> sInventoryConne ction =
        >>> System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")
        >>>
        >>> Unfortunately, this does not read the config file.
        >>>
        >>> I'd sure appreciate any advice.
        >>>
        >>> Thanks, Steve Enzer
        >>>
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Steve Enzer

          #5
          Re: Configuration file read problem

          Phil, this finally worked. I spent a lot of time going thru Microsoft's
          help files and it's too bad they weren't more explicit about this topic.

          Much thanks,
          Steve

          "Phil G." <Phil@nospam.co m> wrote in message
          news:dgsdrf$rm$ 1@nwrdmz01.dmz. ncs.ea.ibs-infra.bt.com...[color=blue]
          > Steve,
          >
          > try this. Add a new item to your project and select the Application
          > Configuration. Don't change the default name app.config. Now open this
          > config file and copy/paste from your original into this new one.
          >
          > Now, when you build your project it will automatically create the
          > project.exe.con fig file for you and place it in the bin folder!
          >
          > HTH, Phil
          >[/color]


          Comment

          Working...