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. Web Development
  3. ASP.NET
  4. How to store "connection string" in global.asax file and web.config file using c#?

How to store "connection string" in global.asax file and web.config file using c#?

Scheduled Pinned Locked Moved ASP.NET
csharptutorialquestion
4 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.
  • S Offline
    S Offline
    sacr83
    wrote on last edited by
    #1
    1. How to store "connection string" in global.asax file and web.config file using c#? 2) How to get that "connection string" from web.config file and global.asax file to My web application? 3)Where i have to call that connection string on My web application and how i call to that connection from My web application..?

    CheeN

    Y 1 Reply Last reply
    0
    • S sacr83
      1. How to store "connection string" in global.asax file and web.config file using c#? 2) How to get that "connection string" from web.config file and global.asax file to My web application? 3)Where i have to call that connection string on My web application and how i call to that connection from My web application..?

      CheeN

      Y Offline
      Y Offline
      Yanela Somdaka
      wrote on last edited by
      #2

      Add the following line in the configuration tag of your web config file Reading it _aseConn.ConnectionString = ConfigurationManager.ConnectionStrings["Name"].ToString(); If you want peace prepare for war...

      S 1 Reply Last reply
      0
      • Y Yanela Somdaka

        Add the following line in the configuration tag of your web config file Reading it _aseConn.ConnectionString = ConfigurationManager.ConnectionStrings["Name"].ToString(); If you want peace prepare for war...

        S Offline
        S Offline
        sacr83
        wrote on last edited by
        #3

        can u post again with how i read it from my web application and how i open that connection @ several times..? thanks alot...

        CheeN

        S 1 Reply Last reply
        0
        • S sacr83

          can u post again with how i read it from my web application and how i open that connection @ several times..? thanks alot...

          CheeN

          S Offline
          S Offline
          Sutheesh chandran
          wrote on last edited by
          #4

          Hi, u can add the connection strings in web.config in appsettings tag. <appSettings> <add key="constr" value="server=10.40.21.8;uid=sa;pwd=password;Database=dbname;"></add> </appSettings> Calling this connection string in .cs file SqlConnection dbConn; String ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"]; dbConn=new SqlConnection(ConnectionString); dbConn.Open();

          Sutheesh Ramachandran Cybernet Software Systems, T Nagar, Chennai 17.

          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