Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Dear Friends
 
I have add a config file to my window form and trying to calling that through my button click with following query..
 
SqlConnection con = new SqlConnection();
        con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
but it is showing Error for ConnectionManager. I have also include Using System.Configuration in form.
 
Please help me I have Vistual Studio 2010
 
Thanks
Posted 25-Jan-13 0:09am
Edited 25-Jan-13 0:10am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

If you are seeing this issue and it's a compilation error, I can pretty much guarantee that you haven't added the reference to System.Configuration.dll. A lot of people seem to think that the configuration manager works from the references you get by default in a VS project.
 
If you expand your References in the solution explorer, you should see that this file is missing. To fix it, add the reference to System.configuration by right clicking on the References node and select Add reference... to open the reference dialog.
 
If, however, it's a runtime error, I would suspect that you don't have a connection string named ConnectionString in your config file. This would result in a null exception when you tried to get the ConnectionString property from the configuration.
 
By the way - when you say you have an error, it's generally a good idea to say what the error actually is. Is it a runtime error? Is it a compilation error?
  Permalink  
Comments
aspnet_regiis -i at 30-Jan-13 6:06am
   
This is the correct answer. The System.Configuration dll reference has to be added. +5
Pete O'Hanlon at 30-Jan-13 8:05am
   
Thanks. I suspect that sisir patro has downvoted it because I pointed out the errors in his answer:)
aspnet_regiis -i at 30-Jan-13 8:18am
   
I agree with your suspicion....I think this guy Sisir patro is insane.. He downvoted my simple and correct answer here .. I am reporting this user as abusive
aspnet_regiis -i at 30-Jan-13 8:33am
   
Pete ! The solutions to this question are deleted.. Any idea how?
Pete O'Hanlon at 30-Jan-13 9:10am
   
Click on the title of the question - it's a hyperlink - it will reopen the question with the answers present again. It did this for me before.
aspnet_regiis -i at 30-Jan-13 9:19am
   
Thanks for the tip..It worked for me.. One more thing..You should check this link ^
Pete O'Hanlon at 30-Jan-13 11:55am
   
:)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

VS2008 will only show the Config manager if the solution node is visible in the Solution Explorer.
 
If you only have a single project, the solution will not show hence you can't see the config manager.
 
To solve this, make sure the following option is checked.
answer:
 
Tools|Options|Projects and Solutions|General|Always Show Solution
 
[Edit]
This user took this information from DaveL's answer to this[^] question in StackOverflow. Full credit goes to the problem solver on Stack Overflow.
 
Edited by Peter O'Hanlon in response to comment about poster plagiarising work.
  Permalink  
v3
Comments
Milind_T at 25-Jan-13 6:35am
   
Copy - Paste ? Who is "Timwi"
Marcus Kramer at 28-Jan-13 11:22am
   
Professionality? Professionals show a link to where they find the answer. Plagiarism is taking credit for someone else's work, which is what you have done here. It is fine to copy/paste an answer from somewhere else, BUT you need to provide a link to that source so that credit is provided to the original source.
Marcus Kramer at 29-Jan-13 10:03am
   
In this community, plagiarism is using ANYONE's work from ANYWHERE without giving credit. Is it really that hard to add a link to where you copied the information from? I don't think so and it is the proper, professional way to do this. Your profile indicates that you are a junior developer. I would suggest you take the advice of someone who has been around for quite a while. Give credit where credit is due.
Pete O'Hanlon at 29-Jan-13 10:24am
   
Actually, your copy and paste is technically incorrect. The poster asked about VS 2010 and you stole the answer to a question about VS 2008. In future, if you steal someone else's work, at least provide a link to that original work - failure to do so will see you banned from the forums.
Marcus Kramer at 25-Jan-13 12:51pm
   
Plagariasm... Source
Sergey Alexandrovich Kryukov at 29-Jan-13 13:53pm
   
Tried to report, but bad guy already gone. We should not let such things pass.
Thank you very much.
—SA
Sergey Alexandrovich Kryukov at 29-Jan-13 13:55pm
   
Did you see the unique case of same-page plagiarism I reported?
http://www.codeproject.com/Messages/4481017/A-unique-case-of-Same-Page-plagiarizm-plagiarizm-a.aspx
—SA
Marcus Kramer at 29-Jan-13 14:05pm
   
I did and I left a comment to that user as well. I didn't want that message to be visible to everyone so I posted the comment so they would get notified with it, but then removed it.
Sergey Alexandrovich Kryukov at 29-Jan-13 15:52pm
   
I understand. Maybe I missed you message somehow...
Thank you,
—SA
Marcus Kramer at 29-Jan-13 16:42pm
   
I removed it right after posting it so the OP would receive it and no one else would see it. It's an easy way to send a "private message".
Sergey Alexandrovich Kryukov at 29-Jan-13 17:04pm
   
Ah, OP. I thought you were talking about the message sent to myself...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 309
1 Richard MacCutchan 295
2 OriginalGriff 270
3 Sharmanuj 146
4 Magic Wonder 129
0 Sergey Alexandrovich Kryukov 5,969
1 OriginalGriff 5,005
2 CPallini 2,473
3 Richard MacCutchan 1,547
4 Abhinav S 1,507


Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100