Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

c# error

Posted on 2011-03-12
6
Medium Priority
?
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 143

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 143

Accepted Solution

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

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

597 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