ConnectionString not initialized..?

Discussion in 'ASP .Net' started by Kent Johnson, Oct 1, 2005.

  1. Kent Johnson

    Kent Johnson Guest

    Hi all,

    I have accidentally deleted my web.config file so I'll have to recreate it.

    I have tried this in my Web.config file:
    <configuration>
    <appSettings>
    <add key="ConnectionString"
    value="server=localhost;uid=sa;password=MyPwd;database=MyDB"/>
    </appSettings>

    When I run this I get:
    "The ConnectionString property has not been initialized."

    What can be wrong?

    /Kent J.
    Kent Johnson, Oct 1, 2005
    #1
    1. Advertising

  2. Kent,

    In the connection string you just added are you certain your key name is the
    same as the old one?

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Kent Johnson" <> wrote in message
    news:6Dw%e.147416$...
    > Hi all,
    >
    > I have accidentally deleted my web.config file so I'll have to recreate
    > it.
    >
    > I have tried this in my Web.config file:
    > <configuration>
    > <appSettings>
    > <add key="ConnectionString"
    > value="server=localhost;uid=sa;password=MyPwd;database=MyDB"/>
    > </appSettings>
    >
    > When I run this I get:
    > "The ConnectionString property has not been initialized."
    >
    > What can be wrong?
    >
    > /Kent J.
    >
    >
    S. Justin Gengo, Oct 1, 2005
    #2
    1. Advertising

  3. Kent Johnson

    Kent Johnson Guest

    Everyting is just the same.
    It worked yesterday.

    In page code behind:
    string conn =
    System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];


    "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
    message news:...
    > Kent,
    >
    > In the connection string you just added are you certain your key name is

    the
    > same as the old one?
    >
    > --
    > Sincerely,
    >
    > S. Justin Gengo, MCP
    > Web Developer / Programmer
    >
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzsche
    > "Kent Johnson" <> wrote in message
    > news:6Dw%e.147416$...
    > > Hi all,
    > >
    > > I have accidentally deleted my web.config file so I'll have to recreate
    > > it.
    > >
    > > I have tried this in my Web.config file:
    > > <configuration>
    > > <appSettings>
    > > <add key="ConnectionString"
    > > value="server=localhost;uid=sa;password=MyPwd;database=MyDB"/>
    > > </appSettings>
    > >
    > > When I run this I get:
    > > "The ConnectionString property has not been initialized."
    > >
    > > What can be wrong?
    > >
    > > /Kent J.
    > >
    > >

    >
    >
    Kent Johnson, Oct 1, 2005
    #3
  4. re:
    <configuration>
    <appSettings>
    <add key="ConnectionString"
    value="server=localhost;uid=sa;password=MyPwd;database=MyDB"/>
    </appSettings>

    Try :
    <configuration>
    <system.web>
    <appSettings>
    etc...

    The appSettings key must be within <system.web>

    btw, check Scott's great pointer on how to encapsulate
    your configuration settings :

    http://odetocode.com/Articles/345.aspx

    Try it. There's more than one way to skin a cat... ;-)




    Juan T. Llibre, ASP.NET MVP
    ASP.NET FAQ : http://asp.net.do/faq/
    Foros de ASP.NET en Español : http://asp.net.do/foros/
    ======================================
    "Kent Johnson" <> wrote in message
    news:LNw%e.147417$...
    > Everyting is just the same.
    > It worked yesterday.
    >
    > In page code behind:
    > string conn =
    > System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
    >
    >
    > "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
    > message news:...
    >> Kent,
    >>
    >> In the connection string you just added are you certain your key name is

    > the
    >> same as the old one?
    >>
    >> --
    >> Sincerely,
    >>
    >> S. Justin Gengo, MCP
    >> Web Developer / Programmer
    >>
    >> www.aboutfortunate.com
    >>
    >> "Out of chaos comes order."
    >> Nietzsche
    >> "Kent Johnson" <> wrote in message
    >> news:6Dw%e.147416$...
    >> > Hi all,
    >> >
    >> > I have accidentally deleted my web.config file so I'll have to recreate
    >> > it.
    >> >
    >> > I have tried this in my Web.config file:
    >> > <configuration>
    >> > <appSettings>
    >> > <add key="ConnectionString"
    >> > value="server=localhost;uid=sa;password=MyPwd;database=MyDB"/>
    >> > </appSettings>
    >> >
    >> > When I run this I get:
    >> > "The ConnectionString property has not been initialized."
    >> >
    >> > What can be wrong?
    >> >
    >> > /Kent J.
    Juan T. Llibre, Oct 1, 2005
    #4
  5. Kent Johnson

    Kent Johnson Guest

    OK! Great!
    Now it works on my localhost!
    What is the best way to export my project to production server?
    File/Save as/http://MyServer/MyProject...?



    "Juan T. Llibre" <> wrote in message
    news:...
    > re:
    > <configuration>
    > <appSettings>
    > <add key="ConnectionString"
    > value="server=localhost;uid=sa;password=MyPwd;database=MyDB"/>
    > </appSettings>
    >
    > Try :
    > <configuration>
    > <system.web>
    > <appSettings>
    > etc...
    >
    > The appSettings key must be within <system.web>
    >
    > btw, check Scott's great pointer on how to encapsulate
    > your configuration settings :
    >
    > http://odetocode.com/Articles/345.aspx
    >
    > Try it. There's more than one way to skin a cat... ;-)
    >
    >
    >
    >
    > Juan T. Llibre, ASP.NET MVP
    > ASP.NET FAQ : http://asp.net.do/faq/
    > Foros de ASP.NET en Español : http://asp.net.do/foros/
    > ======================================
    > "Kent Johnson" <> wrote in message
    > news:LNw%e.147417$...
    > > Everyting is just the same.
    > > It worked yesterday.
    > >
    > > In page code behind:
    > > string conn =
    > >

    System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
    > >
    > >
    > > "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
    > > message news:...
    > >> Kent,
    > >>
    > >> In the connection string you just added are you certain your key name

    is
    > > the
    > >> same as the old one?
    > >>
    > >> --
    > >> Sincerely,
    > >>
    > >> S. Justin Gengo, MCP
    > >> Web Developer / Programmer
    > >>
    > >> www.aboutfortunate.com
    > >>
    > >> "Out of chaos comes order."
    > >> Nietzsche
    > >> "Kent Johnson" <> wrote in message
    > >> news:6Dw%e.147416$...
    > >> > Hi all,
    > >> >
    > >> > I have accidentally deleted my web.config file so I'll have to

    recreate
    > >> > it.
    > >> >
    > >> > I have tried this in my Web.config file:
    > >> > <configuration>
    > >> > <appSettings>
    > >> > <add key="ConnectionString"
    > >> > value="server=localhost;uid=sa;password=MyPwd;database=MyDB"/>
    > >> > </appSettings>
    > >> >
    > >> > When I run this I get:
    > >> > "The ConnectionString property has not been initialized."
    > >> >
    > >> > What can be wrong?
    > >> >
    > >> > /Kent J.

    >
    >
    Kent Johnson, Oct 2, 2005
    #5
  6. re:
    >> The appSettings key must be within <system.web>

    > Now it works on my localhost!


    Good to know!
    Sometimes it's the little things which snag us.

    :)

    re:
    > What is the best way to export my project to production server?


    I usually use "Copy Web", but there's quite a few ways to do that.





    Juan T. Llibre, ASP.NET MVP
    ASP.NET FAQ : http://asp.net.do/faq/
    Foros de ASP.NET en Español : http://asp.net.do/foros/
    ======================================
    "Kent Johnson" <> wrote in message
    news:f0R%e.147525$...
    > OK! Great!
    > Now it works on my localhost!
    > What is the best way to export my project to production server?
    > File/Save as/http://MyServer/MyProject...?
    >
    >
    >
    > "Juan T. Llibre" <> wrote in message
    > news:...
    >> re:
    >> <configuration>
    >> <appSettings>
    >> <add key="ConnectionString"
    >> value="server=localhost;uid=sa;password=MyPwd;database=MyDB"/>
    >> </appSettings>
    >>
    >> Try :
    >> <configuration>
    >> <system.web>
    >> <appSettings>
    >> etc...
    >>
    >> The appSettings key must be within <system.web>
    >>
    >> btw, check Scott's great pointer on how to encapsulate
    >> your configuration settings :
    >>
    >> http://odetocode.com/Articles/345.aspx
    >>
    >> Try it. There's more than one way to skin a cat... ;-)
    >>
    >>
    >>
    >>
    >> Juan T. Llibre, ASP.NET MVP
    >> ASP.NET FAQ : http://asp.net.do/faq/
    >> Foros de ASP.NET en Español : http://asp.net.do/foros/
    >> ======================================
    >> "Kent Johnson" <> wrote in message
    >> news:LNw%e.147417$...
    >> > Everyting is just the same.
    >> > It worked yesterday.
    >> >
    >> > In page code behind:
    >> > string conn =
    >> >

    > System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
    >> >
    >> >
    >> > "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
    >> > message news:...
    >> >> Kent,
    >> >>
    >> >> In the connection string you just added are you certain your key name

    > is
    >> > the
    >> >> same as the old one?
    >> >>
    >> >> --
    >> >> Sincerely,
    >> >>
    >> >> S. Justin Gengo, MCP
    >> >> Web Developer / Programmer
    >> >>
    >> >> www.aboutfortunate.com
    >> >>
    >> >> "Out of chaos comes order."
    >> >> Nietzsche
    >> >> "Kent Johnson" <> wrote in message
    >> >> news:6Dw%e.147416$...
    >> >> > Hi all,
    >> >> >
    >> >> > I have accidentally deleted my web.config file so I'll have to

    > recreate
    >> >> > it.
    >> >> >
    >> >> > I have tried this in my Web.config file:
    >> >> > <configuration>
    >> >> > <appSettings>
    >> >> > <add key="ConnectionString"
    >> >> > value="server=localhost;uid=sa;password=MyPwd;database=MyDB"/>
    >> >> > </appSettings>
    >> >> >
    >> >> > When I run this I get:
    >> >> > "The ConnectionString property has not been initialized."
    >> >> >
    >> >> > What can be wrong?
    >> >> >
    >> >> > /Kent J.

    >>
    >>

    >
    >
    Juan T. Llibre, Oct 2, 2005
    #6
    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. Shapper
    Replies:
    2
    Views:
    2,877
    TDAVISJR
    Apr 23, 2005
  2. Laura K
    Replies:
    12
    Views:
    44,355
    brenk
    May 15, 2010
  3. Dave
    Replies:
    3
    Views:
    5,856
  4. =?Utf-8?B?REo=?=

    Connectionstring User and Password Not Being Used

    =?Utf-8?B?REo=?=, Jun 21, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    465
    =?Utf-8?B?REo=?=
    Jun 22, 2006
  5. RAM
    Replies:
    0
    Views:
    568
Loading...

Share This Page