appconfig

T

Teemu Keiski

Hi,

first of all: *.config files are case.sensitive and second: to add key/value
settings, you'd use <add> element.

Your config should be:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="connectionstring"
value="server=(local);Trusted_Connection=yes;database=Northwind" />
</appSettings>
</configuration>

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


I have no idea why I get error message

An unhandled exception of type
'System.Configuration.ConfigurationException' occured in system.dll

Additional information: Unrecognised configuration section AppSettings

Here is the App.Config files details

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<AppSettings>

<Key="connectionstring" value="server=(local);Trusted_Connection=yes;
database=Northwind"/>

</AppSettings>

</configuration>



and all i want to do is to shoe the value of the connectiostring in a
message box in the form load event, as below.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

MsgBox(System.Configuration.ConfigurationSettings.AppSettings.Get("connectio
nstring"))

End Sub



Surely its not that difficult to spot what I am doing wrong I have copied
and recopied this out time and time again but still cannot read the key
value in the event????



David
 
C

Cowboy \(Gregory A. Beamer\)

<add key="connectionstring" value="" />

That is first. I think you can also simplify the Get() like so (works in
C#):

MsgBox(System.Configuration.ConfigurationSettings.AppSettings("connectionstr
ing")

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
B

Bob Powell [MVP]

David,

Your clock settings are wrong. Please correct it.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*

The GDI+ FAQ: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41

*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*RSS*
 
D

David Mercer

I have no idea why I get error message

An unhandled exception of type
'System.Configuration.ConfigurationException' occured in system.dll

Additional information: Unrecognised configuration section AppSettings

Here is the App.Config files details

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<AppSettings>

<Key="connectionstring" value="server=(local);Trusted_Connection=yes;
database=Northwind"/>

</AppSettings>

</configuration>



and all i want to do is to shoe the value of the connectiostring in a
message box in the form load event, as below.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

MsgBox(System.Configuration.ConfigurationSettings.AppSettings.Get("connectio
nstring"))

End Sub



Surely its not that difficult to spot what I am doing wrong I have copied
and recopied this out time and time again but still cannot read the key
value in the event????



David
 
B

babybinta1

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