ConnectionString not initialized..?

  • Thread starter Thread starter Kent Johnson
  • Start date Start date
K

Kent Johnson

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,

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
 
Everyting is just the same.
It worked yesterday.

In page code behind:
string conn =
System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
 
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 said:
Everyting is just the same.
It worked yesterday.

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


S. Justin Gengo said:
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
 
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 said:
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 said:
Everyting is just the same.
It worked yesterday.

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


S. Justin Gengo said:
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
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.
 
re:
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 said:
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 said:
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 said:
Everyting is just the same.
It worked yesterday.

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


message 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
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.
 
Back
Top