Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8095211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:02:55+00:00 2026-06-05T21:02:55+00:00

this is my common app.config <?xml version=1.0 encoding=utf-8 ?> <configuration> <connectionStrings> <add name=BO connectionString=Data

  • 0

this is my common app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="BO"
        connectionString="Data Source=MyServer;Initial Catalog=BO;User ID=WebUser;Password=xxxx"
        providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

And I’m working on a library, class.cs. Here’s the part of the code where I get the error.

 public static SqlConnection getNewConnection()
        {
            string conection = ConfigurationManager.ConnectionStrings["BO"].ConnectionString.ToString();
            conn = new SqlConnection(conection);
            return conn;
        }

Error 1 The name ‘conn’ does not exist in the current context

Any idea? I have not copied any other file that’s being referenced to the same file. (some error I’ve read is common when it comes to “does not exist in the current context”)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:02:57+00:00Added an answer on June 5, 2026 at 9:02 pm

    Where is conn declared ? Did you already declare it in an outer scope ? If not, declare it and you will be good.

    Change this line

     conn = new SqlConnection(conection);
    

    to

     SqlConnection conn = new SqlConnection(conection);
    

    You can alternatively use implicit declaration using the var keyword. It is available from C# 3.0 onwards.

     var conn = new SqlConnection(conection);
    

    The compiler will infer the type of the variable from the expression on the right side of the initialization statement

    from msdn

    An implicitly typed local variable is strongly typed just as if you
    had declared the type yourself, but the compiler determines the type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in common, hibernate sessionfactory is created in spring configuration file (eg spring-dao.xml) like; <bean
I have this kind of path architecture : >main_path/ __init__.py config/ __init__.py common.py app_1/
My current solution has 3 project with 2 app.config (one for common settings and
There are numerous resources available on WCF and configuration (both programmatic and via app.config).
Short Version : I'm using a 64bit dll (system.data.sqlite) in an Asp.net MVC app
I have this common issue of 'new line' in php-csv which is making me
I was wondering if this common IDE feature is available. Suppose I open many
In Bash I can create a map (hashtable) with this common construction hput() {
I am looking for a general and complete solution to this common problem! I
I'm taking over a project and wanted to understand if this is common practice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.