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. hi need help with configurationmanager

hi need help with configurationmanager

Scheduled Pinned Locked Moved C#
csharpasp-netvisual-studiohelpquestion
6 Posts 3 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.
  • N Offline
    N Offline
    neodeaths
    wrote on last edited by
    #1

    SqlConnection conn = new SqlConnection((ConfigurationManager.ConnectionStrings["HASDBConnectionString1"]).ToString()); hi the above code is what i used in my asp.net to get the connection string from the web.config now i am trying to get the connection string for my c# window application using visual studio 2005 project but it sseems the same code dont work can any one show me how?

    B 1 Reply Last reply
    0
    • N neodeaths

      SqlConnection conn = new SqlConnection((ConfigurationManager.ConnectionStrings["HASDBConnectionString1"]).ToString()); hi the above code is what i used in my asp.net to get the connection string from the web.config now i am trying to get the connection string for my c# window application using visual studio 2005 project but it sseems the same code dont work can any one show me how?

      B Offline
      B Offline
      BAIJUMAX
      wrote on last edited by
      #2

      Check System.Configuration namespace. alternatively My suggestion is to create custom ConfigurationManager sigleton class , initialize at the startup. BAIJUMAX :cool: "Coolest thing on earth is...? Guess what? as per my knowledge 'ICE' , anythingelse pl's let me know ":-O

      N 1 Reply Last reply
      0
      • B BAIJUMAX

        Check System.Configuration namespace. alternatively My suggestion is to create custom ConfigurationManager sigleton class , initialize at the startup. BAIJUMAX :cool: "Coolest thing on earth is...? Guess what? as per my knowledge 'ICE' , anythingelse pl's let me know ":-O

        N Offline
        N Offline
        Nouman Bhatti
        wrote on last edited by
        #3

        In desktop application u should use System.Configuration.ConfigurationSettings.AppSettings.Get("ElementName")

        N 1 Reply Last reply
        0
        • N Nouman Bhatti

          In desktop application u should use System.Configuration.ConfigurationSettings.AppSettings.Get("ElementName")

          N Offline
          N Offline
          neodeaths
          wrote on last edited by
          #4

          <configuration> <add name="HASDBConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HASDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </configuration> hi the above is the part of the configuration file that i am trying to get.. the connection string part. i tried your method but it doesnt seems to work could you please try to help me again pls?

          N 1 Reply Last reply
          0
          • N neodeaths

            <configuration> <add name="HASDBConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HASDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </configuration> hi the above is the part of the configuration file that i am trying to get.. the connection string part. i tried your method but it doesnt seems to work could you please try to help me again pls?

            N Offline
            N Offline
            Nouman Bhatti
            wrote on last edited by
            #5

            you have to modify your app.config file to look like above. then u can use what i said earlier.. try it and if u still not been able to do it. then i'll make a sample for u.

            N 1 Reply Last reply
            0
            • N Nouman Bhatti

              you have to modify your app.config file to look like above. then u can use what i said earlier.. try it and if u still not been able to do it. then i'll make a sample for u.

              N Offline
              N Offline
              neodeaths
              wrote on last edited by
              #6

              yes an sample would be nice thx u as my situation is that i am trying to use the connection string in my app.config however i only know how to do it in an window application thx in advance

              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