Solved

c# error

Posted on 2011-03-12
6
187 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 78
Different Delete Messages 7 37
What's the most efficient way to load up a couple of large table in C#? 5 33
c# string handling 1 26
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

10 Experts available now in Live!

Get 1:1 Help Now