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. error while adding connectionstring dynamically

error while adding connectionstring dynamically

Scheduled Pinned Locked Moved ASP.NET
helpworkspace
5 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.
  • M Offline
    M Offline
    mnarayana3
    wrote on last edited by
    #1

    the error is coming while i am using the following code. This is for add a connection string to datasource dynamically code: string cnStr; cnStr = ConfigurationSettings.ConnectionStrings["MyNWind"].ConnectionString; SqlConnection cnObj = new SqlConnection(cnStr); error: 'System.Configuration.ConfigurationSettings' does not contain a definition for 'ConnectionStrings' itsvery urgent. TIA

    S D 2 Replies Last reply
    0
    • M mnarayana3

      the error is coming while i am using the following code. This is for add a connection string to datasource dynamically code: string cnStr; cnStr = ConfigurationSettings.ConnectionStrings["MyNWind"].ConnectionString; SqlConnection cnObj = new SqlConnection(cnStr); error: 'System.Configuration.ConfigurationSettings' does not contain a definition for 'ConnectionStrings' itsvery urgent. TIA

      S Offline
      S Offline
      Sherin Iranimose
      wrote on last edited by
      #2

      Hi, Did you add a key like this inside your web.config file I think you should add like this. <connectionStrings> <add name="MyNWind" connectionString="My Connection String" /> </connectionStrings>


      To succeed, we must first believe that we can. Sherin Iranimose


      M 2 Replies Last reply
      0
      • S Sherin Iranimose

        Hi, Did you add a key like this inside your web.config file I think you should add like this. <connectionStrings> <add name="MyNWind" connectionString="My Connection String" /> </connectionStrings>


        To succeed, we must first believe that we can. Sherin Iranimose


        M Offline
        M Offline
        mnarayana3
        wrote on last edited by
        #3

        yes i did that. but still its giving error

        1 Reply Last reply
        0
        • S Sherin Iranimose

          Hi, Did you add a key like this inside your web.config file I think you should add like this. <connectionStrings> <add name="MyNWind" connectionString="My Connection String" /> </connectionStrings>


          To succeed, we must first believe that we can. Sherin Iranimose


          M Offline
          M Offline
          mnarayana3
          wrote on last edited by
          #4

          here is the code in home.aspx: SqlDataSource ds = new SqlDataSource(); ds.ConnectionString = ConfigurationSettings.connectionStrings["ConnectionString2"].connectionString; ds.SelectCommand = "SELECT DEPTNO, DNAME FROM DEPT1 where deptno=@deptno"; here is the code in web.config: i alreadymentioned my error that what i am getting. try to help me asap. TIA

          1 Reply Last reply
          0
          • M mnarayana3

            the error is coming while i am using the following code. This is for add a connection string to datasource dynamically code: string cnStr; cnStr = ConfigurationSettings.ConnectionStrings["MyNWind"].ConnectionString; SqlConnection cnObj = new SqlConnection(cnStr); error: 'System.Configuration.ConfigurationSettings' does not contain a definition for 'ConnectionStrings' itsvery urgent. TIA

            D Offline
            D Offline
            doWhileSomething
            wrote on last edited by
            #5

            Shouldn't it be: ConfigurationManager.ConnectionStrings["your_con_string"].ToString() Assuming this is for 2.0 and you've added the proper imports/using statement. e.g. (C#) using System.Configuration; (VB) Imports System.Configuration Hope this helps :->

            My Personal Site

            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