Whats Wrong? - XML config file problems
Can anyone tell me where I've gone wrong with this?
Code so far for config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appsettings>
<add key="ConnectionString" value="data source=STKPROD04;initial catalog=STKPRODDB;integrated security=SSPI;persist security info=False" />
</appsettings>
</configuration>
Code in module:
Imports System.Configuration
Imports System.Collections.Specialized
Module ModSubMain
Sub Main()
Dim sAttr As String
sAttr = System.Configuration.ConfigurationSettings.AppSettings("ConnectionString")
Debug.WriteLine("The value of key: " & sAttr)
Dim sAll As NameValueCollection
sAll = ConfigurationSettings.AppSettings()
End Sub
End Module
When this runs I receive an error message:
An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.dll
Additional information: Unrecognized configuration section appsettings
This error is received on the line:
sAttr = System.Configuration.ConfigurationSettings.AppSettings("ConnectionString")
Can anyone see what I have wrong with this code? I'm just trying to create a very simple connection via a config file and have been having a terrible time. Any help ??
Thanks,
Corinne