Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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
Updated 25-Jan-13 0:10am
v2

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?
 
Share this answer
 
Comments
bbirajdar 30-Jan-13 6:06am    
This is the correct answer. The System.Configuration dll reference has to be added. +5
Pete O'Hanlon 30-Jan-13 8:05am    
Thanks. I suspect that sisir patro has downvoted it because I pointed out the errors in his answer:)
bbirajdar 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
bbirajdar 30-Jan-13 8:33am    
Pete ! The solutions to this question are deleted.. Any idea how?
Pete O'Hanlon 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.
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.
 
Share this answer
 
v3
Comments
MT_ 25-Jan-13 6:35am    
Copy - Paste ? Who is "Timwi"
[no name] 27-Jan-13 23:24pm    
yes dear, i just simply do copy and paste only , but before that why r u not answering this question...?. I don't no the exact answer , but my intensity is to help to others that's way i search in google and answer that question..., i'm not excepting voting , i'm not participating any debat contest...? right . I don't no this is the exact solution or not but when i search in google this answer also available i'm checking with my PC this works fine for me, that's way i post that answer. If you know the answer ..,i'm asking you why are you not posting the answer..?. Everybody comment to others , but no one resopnd in proper way why..? this is your professionality...?
fjdiewornncalwe 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.
[no name] 29-Jan-13 4:59am    
In that link having bulk of data so, in that i'm selecting few lines only. how the end user know which line is exact satisfy the requirement.

Plagiarism is taking credit for someone else's work, which is what you have done here, i'm not expecting any one complements... k,

my intensity is, my answer is solve the user problem or not, that's enough...

if you think in wrong direction that's not an issue ..

i'm asking you if you know the answer why are you not respond this question...?

why because you spend a time for complements....

but i'm not expecting any complements....

professionality means not only in subject wise , the way we are thinking, the way we are accepting the other persons suggestions... it's depending upon the way we behave in social networks
fjdiewornncalwe 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.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900