Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to call connection string from web.config

How to call connection string from web.config

Scheduled Pinned Locked Moved C#
helpcsharptutorialquestionworkspace
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mwith
    wrote on last edited by
    #1

    Hi, I stored connection string in web.config file. and I call it in c# program as follows. SqlConnection cn; sConn = ConfigurationSettings.AppSettings("dbconnection"); cn = new SqlConnection(sConn); cn.Open(); then it is giving a error message 'System.Configuration.ConfigurationSettings.AppSettings' denotes a 'property' where a 'method' was expected please I am a new programmer. can anyone help me? Thank you.

    K 1 Reply Last reply
    0
    • M mwith

      Hi, I stored connection string in web.config file. and I call it in c# program as follows. SqlConnection cn; sConn = ConfigurationSettings.AppSettings("dbconnection"); cn = new SqlConnection(sConn); cn.Open(); then it is giving a error message 'System.Configuration.ConfigurationSettings.AppSettings' denotes a 'property' where a 'method' was expected please I am a new programmer. can anyone help me? Thank you.

      K Offline
      K Offline
      kinnuP
      wrote on last edited by
      #2

      hi , u have to call the ConfigurationSettings.AppSettings["dbconnection"]; place u r asp.net questions in asp.net form not in C# u will get quick responce -- modified at 6:02 Thursday 23rd November, 2006

      P.gurukiran

      C 1 Reply Last reply
      0
      • K kinnuP

        hi , u have to call the ConfigurationSettings.AppSettings["dbconnection"]; place u r asp.net questions in asp.net form not in C# u will get quick responce -- modified at 6:02 Thursday 23rd November, 2006

        P.gurukiran

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        kinnuP wrote:

        u

        kinnuP wrote:

        r

        Please write properly - TXTSPK is difficult to understand and you are not constrained to 160 characters.

        kinnuP wrote:

        place u r asp.net questions in asp.net form not in C#

        This question was NOT specific to ASP.NET. The answer, which YOU gave, was a correction of C# syntax - Other than a reference to web.config (and it could just have easily been app.config, because the C# code to access that is no different), it had nothing to do with ASP.NET.


        Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

        K 1 Reply Last reply
        0
        • C Colin Angus Mackay

          kinnuP wrote:

          u

          kinnuP wrote:

          r

          Please write properly - TXTSPK is difficult to understand and you are not constrained to 160 characters.

          kinnuP wrote:

          place u r asp.net questions in asp.net form not in C#

          This question was NOT specific to ASP.NET. The answer, which YOU gave, was a correction of C# syntax - Other than a reference to web.config (and it could just have easily been app.config, because the C# code to access that is no different), it had nothing to do with ASP.NET.


          Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

          K Offline
          K Offline
          kinnuP
          wrote on last edited by
          #4

          sorry

          P.gurukiran

          M 1 Reply Last reply
          0
          • K kinnuP

            sorry

            P.gurukiran

            M Offline
            M Offline
            mwith
            wrote on last edited by
            #5

            I tried it again with App.config file. but same error is comming. pls can you help me? Thanks

            E 1 Reply Last reply
            0
            • M mwith

              I tried it again with App.config file. but same error is comming. pls can you help me? Thanks

              E Offline
              E Offline
              Eduard Keilholz
              wrote on last edited by
              #6

              Probably not an error, but a warning. The appsettings is obsolete since VS.NET 2005. Create a reference to System.Configuration and use : System.Configuration.ConfigurationManager.AppSettings["SettingName"]; That should do the trick ;-)

              - - - --[ i love it when a plan comes together ]-- - - -

              M 1 Reply Last reply
              0
              • E Eduard Keilholz

                Probably not an error, but a warning. The appsettings is obsolete since VS.NET 2005. Create a reference to System.Configuration and use : System.Configuration.ConfigurationManager.AppSettings["SettingName"]; That should do the trick ;-)

                - - - --[ i love it when a plan comes together ]-- - - -

                M Offline
                M Offline
                mwith
                wrote on last edited by
                #7

                :((I tried that again, then it is an another error called: The type or namespace name 'ConfigurationManager' does not exist in the class or namespace 'System.Configuration' (are you missing an assembly reference?) I am a beginner for c# can you help me? thank you

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups