Exception: The ConnectionString property has not been initialized

J

Justin Doh

Hello.
I had this error for a long time, and I need some help.

My program is a very simple System.Web.Mail program that calls a stored
procedure “spSendEmailNotification†and get data.
And based on the value that I get from the stored procedure, Web Mail is
sent of not.

Basically, I get this error when I execute an EXE file using Command Prompt:
“Exception: The ConnectionString property has not been initializedâ€

My first approach was looking at the Web.Config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Prod" value="server=SQL1;database=Prod;Integrated Security=SSPI"
/>

Or should I use this?? I am not sure what to add for the Password.. I just
guessed.

<add key="Prod" value="User ID=prod_group;Password=prod^group;data
source=SQL1;persist security info=True;initial catalog=Prod" />


After getting the error, I added the following lines inside <configuration>
at the Web.Config file inside <configuration> hoping that it would resolve
the error.

<connectionStrings>
<add name="Prod"
connectionString="Data Source=SQL1;Integrated Security=SSPI;Initial
Catalog=Prod;"
providerName="System.Data.SqlClient" />
</connectionStrings>



This is what is written at the business layer.

Public Function getEmailNotify() As DataSet
Return obj.GetData("spSendEmailNotification",
System.Configuration.ConfigurationSettings.AppSettings.Get("Prod"))
End Function


I would appreciate if anyone gives me some feedback.

Thanks in advance.
 
N

Norman Yuan

Simply do a debugging to see if the ConnectionString is actually loaded from
web.config or not:

Public Function getEmailNotify() As DataSet

''Place breakpoint HERE, to see what value "cn" gets, so you know the
setting is read in correctly ornot.
Dim cn As
String=System.Configuration.ConfigurationSettings.AppSettings.Get("Prod")

Return obj.GetData("spSendEmailNotification", cn)

End Function
 
J

Justin Doh

Actually, I am not sure whether it is still causing an error or not.

This is what is showing after debug.
At the end, it indicates "..has existed with code 0 (0x0)", but it still
shows the message "Exception: The ConnectionString property has not been
initialized" at the command prompt.
----------------------------------------------------------------------------------
'DefaultDomain': Loaded
'c:\winnt\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'RootCause2': Loaded 'P:\My Documents\Work-others\Other
Misc\bin\RootCause2.exe', No symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\microsoft.visualbasic\7.0.5000.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll', No symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll', No symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No
symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll', No symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll', No symbols loaded.
'RootCause2.exe': Loaded 'p:\my documents\work-others\other
misc\bin\libdata.dll', No symbols loaded.
The program '[1356] RootCause2.exe' has exited with code 0 (0x0).

I am not sure what is going on.
Any feedback is appreciated.

Thanks in advance.
Justin
 
J

Justin Doh

I did not debug as "debug" mode but as "Release" mode last time.

But even when I debugged as "debug" mode, it did have any value for the cn.

What might be an issue?
I would appreciate for any feedback.

Thanks.

Justin Doh said:
Actually, I am not sure whether it is still causing an error or not.

This is what is showing after debug.
At the end, it indicates "..has existed with code 0 (0x0)", but it still
shows the message "Exception: The ConnectionString property has not been
initialized" at the command prompt.
----------------------------------------------------------------------------------
'DefaultDomain': Loaded
'c:\winnt\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'RootCause2': Loaded 'P:\My Documents\Work-others\Other
Misc\bin\RootCause2.exe', No symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\microsoft.visualbasic\7.0.5000.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll', No symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll', No symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No
symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll', No symbols loaded.
'RootCause2.exe': Loaded
'c:\winnt\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll', No symbols loaded.
'RootCause2.exe': Loaded 'p:\my documents\work-others\other
misc\bin\libdata.dll', No symbols loaded.
The program '[1356] RootCause2.exe' has exited with code 0 (0x0).

I am not sure what is going on.
Any feedback is appreciated.

Thanks in advance.
Justin


Norman Yuan said:
Simply do a debugging to see if the ConnectionString is actually loaded from
web.config or not:

Public Function getEmailNotify() As DataSet

''Place breakpoint HERE, to see what value "cn" gets, so you know the
setting is read in correctly ornot.
Dim cn As
String=System.Configuration.ConfigurationSettings.AppSettings.Get("Prod")

Return obj.GetData("spSendEmailNotification", cn)

End Function
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top