option strict disallows late binding reading from web.config

Discussion in 'ASP .Net' started by Karl Lang, Jun 1, 2004.

  1. Karl Lang

    Karl Lang Guest

    Hi
    I've created a new configuration section in Web.Config to hold the
    connection string for my database. If I have Option Strict On I get a
    message "Option Strict On disallows late binding" when I try to retrieve the
    string. Now I'd rather not turn off option strict but I'd also prefer to
    have my connection string in one place. Does anyone have any ideas where I'm
    going wrong with this?

    This is the code
    In Web.Config (I've removed some of the type in the section name):
    <configSections>
    <section name="MyWebSite"
    type="System.Configuration.NameValueFileSectionHandler..." />
    </configSections>

    <MyWebSite>
    <add key="connString"
    value="server=(local);uid=x.xxx;pwd=xxx;database=xyzxyz" />
    </MyWebSite>



    In my ASPX file, the following produces the late binding error message:
    strConn = ConfigurationSettings.GetConfig("MyWebSite")("connString")

    klang
     
    Karl Lang, Jun 1, 2004
    #1
    1. Advertising

  2. Karl Lang

    Karl Lang Guest

    "Karl Lang" <> wrote in message
    news:...
    > In Web.Config (I've removed some of the type in the section name):
    > <configSections>
    > <section name="MyWebSite"
    > type="System.Configuration.NameValueFileSectionHandler..." />
    > </configSections>
    >


    Hi again,
    you can ignore my post, after re-reading the online docs I have used
    appSettings section to hold my connection string.

    btw, it also appears that I shouldn't have used NameValueFileSectionHandler.
    If anyone is interested in section groups check out Declaring and Accessing
    Section Groups at msdn,
    http://msdn.microsoft.com/library/d.../cpguide/html/cpcondeclaringsectiongroups.asp

    klang
     
    Karl Lang, Jun 1, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan McLean

    Option Strict On disallows late binding.

    Ryan McLean, Jun 14, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,376
    mikeb
    Jun 14, 2004
  2. Owen Mortensen
    Replies:
    7
    Views:
    3,168
    Owen Mortensen
    Mar 13, 2006
  3. Adotek
    Replies:
    1
    Views:
    446
    Bruno Alexandre
    Oct 3, 2006
  4. Chris Davey via .NET 247

    Option Strict On disallows late binding

    Chris Davey via .NET 247, Apr 6, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    178
    Brock Allen
    Apr 6, 2005
  5. Seema
    Replies:
    1
    Views:
    871
    Arne Vajhøj
    Jan 25, 2012
Loading...

Share This Page