Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

c# error

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
vbnetcoder
Asked:
vbnetcoder
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
try:

string conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"];
0
 
vbnetcoderAuthor Commented:
It tells me that I can't exlicitly convert it to string
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
np:
string conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString();

Open in new window

0
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!

 
Todd GerbertIT ConsultantCommented:
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
 
Carl TawnSystems and Integration DeveloperCommented:
And it should be:
string conString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;

Open in new window

0
 
vbnetcoderAuthor Commented:
ty
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now