944,117 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 8334
  • ASP.NET RSS
May 4th, 2005
0

database string in web.config not working

Expand Post »
hello, i just started to code aspx, but i found troubles adding the connection string in the web.config
i was trying to code the "populate the listbox" tutorial, and in the part of pasting the connection string in the above mentioned file, i'm getting this error
"Only elements allowed"
The debug points to that line in the web.config
Thanks in advance, this web is cool because the tutorials are so well explained, which is hard to find on other sites for noobies like me.
thanks thanks thanks !
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kerberos is offline Offline
1 posts
since Apr 2005
May 5th, 2005
0

Re: database string in web.config not working

Here might be one solution to help you out. This is not my work I found it elsewhere.

ASP.NET Syntax (Toggle Plain Text)
  1. In the web.config file, add the following section
  2.  
  3. <configuration>
  4. <appSettings file="app.config"></appSettings>
  5. </configuration>
  6.  
  7. In a new file, add the following and save it as app.cfg
  8.  
  9.  
  10. <?xml version="1.0" encoding="utf-8" ?>
  11. <appSettings>
  12. <add key="conn" value="Data Source=localhost;Integrated Security=SSPI; database=YourDB" />
  13. </appSettings>


Hope this helps.

Miller
Reputation Points: 11
Solved Threads: 2
Newbie Poster
millers_35 is offline Offline
18 posts
since Apr 2005
Apr 30th, 2007
0

Re: database string in web.config not working

I know the original poster has probably long since solved their problem, but I thought I'd answer for anyone coming along after who faces a similar exception and is confused. Especially since both of the original replies above are either wrong or comment spam.

Now, what this exception generally means is that the XML in the App.Config file is ill-formed. That is, you have probably put something in there that shouldn't be there or something like that. For instance, when I got this error recently, it was because I had accidently put a semi-colon at the end of a key.

I'm not saying this is going to be the answer all the time, but if you get this sort of error, the first thing I would do is go back and check my App.Config file to ensure that you haven't thrown in an extra punctuation mark or the like. Good luck!
Last edited by webbsk; Apr 30th, 2007 at 4:20 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
webbsk is offline Offline
1 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Problems with loading blackplanet.com
Next Thread in ASP.NET Forum Timeline: Create control at runtime





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC