Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

 

Am trying to store my connection string in my web.config file. According to the net, all i have to do is add the following:

<configuration>
<add key="dbconnection" value=" server=(local);
Initial Catalog=Northwind;UID=tester;PWD=123456"/>
</configuration> 

 

However, when I go to run my web app I get a message telling me that there may be syntax problems with my web.config file, and that I should run "Start without Debugger". This in turn tells me that: Parser Error Message: Unrecognized configuration section 'configuration'

 

Any suggestions on how to get around this?

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

in the existing configuration section add a section <appSettings>

 

<appSettings>
<add key="dbconnection" value="server=(local);Initial Catalog=Northwind;UID=tester;PWD=123456"/>
</appSettings>

make sure your values do not span multiple lines

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
in the existing configuration section add a section <appSettings>

 

<appSettings>
<add key="dbconnection" value="server=(local);Initial Catalog=Northwind;UID=tester;PWD=123456"/>
</appSettings>

make sure your values do not span multiple lines

 

 

Had originally tried that but ran into trouble with it, however I went at it again but this time I added the lines to the top of the web config file and it worked. Is it a good idea putting the database string in the web config file or not? Some sites are saying that I should also encrypt the connection string that I am storing, and decrypt the string before I open the database connection.

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

At a minimum you should not put the password in the config file. Add that to the string in the file. Generally all you really need in the file is the database location, the name is probably standard, so the remainder can be built up in code.

How are you going to encrypt the string as this will probably need to be done in advance and you may not know the location until deployment, but you could still do the encryption as part of a custom action in the deployment and add it to the config file.

Hamlet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...