System.InvalidOperationException: The ConnectionString property has not been initialized.
What I am missing? I really need to fix this. Can anyone help me?
Thanks
In my web.config
<appSettings
<add key="connectionstring" value="server=homesvr02;uid=sa;pwd=database=Property"/>
</appSettings
In my asp.net page<%@. Page Language="VB" %>
<%@. Import Namespace="System.Configuration" %>
<%@. import Namespace="System.IO" %>
<%@. import Namespace="System.Data" %>
<%@. import Namespace="System.Data.SQLClient" %
Dim strConn As String = ConfigurationSettings.AppSettings("ConnectionString")
MY ERROR
System.InvalidOperationException: The ConnectionString property has not been initialized.Please show the rest of your code.
Are you creating an instance of SqlConnection?
Are you setting it's ConnectionString property?|||Little error :-)
See this line:
::<add key="connectionstring"
::value="server=homesvr02;uid=sa;pwd=database=Property"/
and then this line:
::Dim strConn As String = ConfigurationSettings.AppSettings("ConnectionString")
I know you come from a VB background - in XML, though casing does matter.
connectionstring != ConnectionString.|||good call there thona. I would have missed that. I think everyone proper cases everything.|||1.
<thona>
::Dim strConn As String = ConfigurationSettings.AppSettings("ConnectionString")
I know you come from a VB background - in XML, though casing does matter.
connectionstring != ConnectionString.
</thona
<KraGiE>
good call there thona. I would have missed that. I think everyone proper cases everything.
</KraGiE
* Well, a quick test using VB.NET and C# said otherwise.
Tricky or Inconsistency. Who would expect that? :-D
* C#
Response.Write(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
* VB.NET
Response.Write(System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"))
Both gives
server=homesvr02;uid=sa;pwd=database=Property
2. Can you guys do a quick test to see too?
3. web.config
|||phouc is right. on both 2002 and 2003. impressive. twice in one day. remarkable
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="connectionstring" value="server=homesvr02;uid=sa;pwd=database=Property"/>
</appSettings>