Solved

c# error

Posted on 2011-03-12
6
186 Views
Last Modified: 2012-08-14
This line:

var conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"];

gives me the error


The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference)

=====
This line


0
Comment
Question by:vbnetcoder
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35118881
try:

string conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"];
0
 

Author Comment

by:vbnetcoder
ID: 35118919
It tells me that I can't exlicitly convert it to string
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35118944
np:
string conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString();

Open in new window

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35119795
Just to expand slightly...the C# keyword var was introduced with Visual Studio 2008, you won't be able to use it with earlier versions.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35126690
And it should be:
string conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;

Open in new window

0
 

Author Closing Comment

by:vbnetcoder
ID: 35157651
ty
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now