mike55 Posted November 24, 2004 Posted November 24, 2004 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 Quote 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)
Administrators PlausiblyDamp Posted November 24, 2004 Administrators Posted November 24, 2004 Are you adding your own configuration section? If so that is probably the problem - the default web.config already has a configuration section and you may be trying to nest yours inside the existing one. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Joe Mamma Posted November 24, 2004 Posted November 24, 2004 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 Quote 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.
mike55 Posted November 24, 2004 Author Posted November 24, 2004 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 Quote 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)
donnacha Posted November 24, 2004 Posted November 24, 2004 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. Quote Hamlet
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.