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. connection string Web.config + ASP.net C#

connection string Web.config + ASP.net C#

Scheduled Pinned Locked Moved ASP.NET
csharpdatabaseasp-netsaleshelp
17 Posts 5 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.
  • R rock_monu
    J Offline
    J Offline
    jojoba2011
    wrote on last edited by
    #3

    what ?

    1 Reply Last reply
    0
    • J jojoba2011

      Hi every one. I have copying my database via setup to Program File of customer system. now how can i give the conection string that can attach the DB (in webconfig):

      I have used "%ProgramFiles%" but no use... Please Help Thanks in Advanced !

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      If you use values like this in your connection string then i think you will need to modify it at execution time in order to replace the %programfiles% with the real path. See Web.config File - ASP.NET[^] for some useful information on the web.config file.

      One of these days I'm going to think of a really clever signature.

      U 1 Reply Last reply
      0
      • L Lost User

        If you use values like this in your connection string then i think you will need to modify it at execution time in order to replace the %programfiles% with the real path. See Web.config File - ASP.NET[^] for some useful information on the web.config file.

        One of these days I'm going to think of a really clever signature.

        U Offline
        U Offline
        User 9427106
        wrote on last edited by
        #5

        Thanks for solution but i didnt get anything..plz give an example how to do that. Thanks in advanced

        L 2 Replies Last reply
        0
        • U User 9427106

          Thanks for solution but i didnt get anything..plz give an example how to do that. Thanks in advanced

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          You need to spend some time getting familiar with MSDN, which contains documentation for just about everything you will ever need, including this section on environment variables[^].

          One of these days I'm going to think of a really clever signature.

          1 Reply Last reply
          0
          • U User 9427106

            Thanks for solution but i didnt get anything..plz give an example how to do that. Thanks in advanced

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #7

            Why have you created a new CodeProject id for this?

            One of these days I'm going to think of a really clever signature.

            U 1 Reply Last reply
            0
            • L Lost User

              Why have you created a new CodeProject id for this?

              One of these days I'm going to think of a really clever signature.

              U Offline
              U Offline
              User 9427106
              wrote on last edited by
              #8

              It was mistake that i create two id... How can i use Environment.ExpandEnvironmentVariables in web.config for connectionstring? Thanks in advanced!

              L 1 Reply Last reply
              0
              • U User 9427106

                It was mistake that i create two id... How can i use Environment.ExpandEnvironmentVariables in web.config for connectionstring? Thanks in advanced!

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #9

                Member 9473809 wrote:

                It was mistake that i create two id...

                Then please post a message here[^] to ask the administrators to remove the duplicate.

                Member 9473809 wrote:

                How can i use Environment.ExpandEnvironmentVariables

                The link to the documentation that I posted contains a code sample, I cannot offer anything that is clearer than that.

                One of these days I'm going to think of a really clever signature.

                J 1 Reply Last reply
                0
                • L Lost User

                  Member 9473809 wrote:

                  It was mistake that i create two id...

                  Then please post a message here[^] to ask the administrators to remove the duplicate.

                  Member 9473809 wrote:

                  How can i use Environment.ExpandEnvironmentVariables

                  The link to the documentation that I posted contains a code sample, I cannot offer anything that is clearer than that.

                  One of these days I'm going to think of a really clever signature.

                  J Offline
                  J Offline
                  jojoba2011
                  wrote on last edited by
                  #10

                  Thanks ! But i didnt find the solution. Isn't there anybody to do that !

                  L 1 Reply Last reply
                  0
                  • J jojoba2011

                    Thanks ! But i didnt find the solution. Isn't there anybody to do that !

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #11

                    You have the solution, it's just that you need to to spend some time modifying it so it suits your specific problem.

                    One of these days I'm going to think of a really clever signature.

                    J 1 Reply Last reply
                    0
                    • L Lost User

                      You have the solution, it's just that you need to to spend some time modifying it so it suits your specific problem.

                      One of these days I'm going to think of a really clever signature.

                      J Offline
                      J Offline
                      jojoba2011
                      wrote on last edited by
                      #12

                      thanks i dont know the solution . Help! if possible give example!

                      L 1 Reply Last reply
                      0
                      • J jojoba2011

                        thanks i dont know the solution . Help! if possible give example!

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #13

                        jojoba2011 wrote:

                        i dont know the solution .Help! if possible give example!

                        There is really no point in you repeatedly posting the same cry. I have given you a link to the method you need to use, which includes a code sample which demonstrates exactly how it can be used to expand an environment variable in a string. Unless you give some more details about how exactly you are trying to use it and why it does not work, then it is unlikely that we can guess what your problem is.

                        One of these days I'm going to think of a really clever signature.

                        J 1 Reply Last reply
                        0
                        • L Lost User

                          jojoba2011 wrote:

                          i dont know the solution .Help! if possible give example!

                          There is really no point in you repeatedly posting the same cry. I have given you a link to the method you need to use, which includes a code sample which demonstrates exactly how it can be used to expand an environment variable in a string. Unless you give some more details about how exactly you are trying to use it and why it does not work, then it is unlikely that we can guess what your problem is.

                          One of these days I'm going to think of a really clever signature.

                          J Offline
                          J Offline
                          jojoba2011
                          wrote on last edited by
                          #14

                          Hi sir, this is exactly what i wanna to use in webconfig:

                          i dont know which drive is system drive (C or D).cause my setup copies the database to %programfiles% . may be C:\program files OR D:\Program files.

                          L J 2 Replies Last reply
                          0
                          • J jojoba2011

                            Hi sir, this is exactly what i wanna to use in webconfig:

                            i dont know which drive is system drive (C or D).cause my setup copies the database to %programfiles% . may be C:\program files OR D:\Program files.

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #15

                            I still don't understand what your problem is. If you follow the documentation in the link I gave you[^], it shows exactly how to get the real path from an environment variable, including the system drive. What more do you need?

                            One of these days I'm going to think of a really clever signature.

                            1 Reply Last reply
                            0
                            • J jojoba2011

                              Hi sir, this is exactly what i wanna to use in webconfig:

                              i dont know which drive is system drive (C or D).cause my setup copies the database to %programfiles% . may be C:\program files OR D:\Program files.

                              J Offline
                              J Offline
                              jkirkerx
                              wrote on last edited by
                              #16

                              I think this is what your looking for. Your example makes no sense to me, and I don't see the point of it. If your sql server is loaded on your hard drive, why not use the standard connection string? As far as using a programmable path like %ProgramFiles%, that's a Windows thing, which works in certain scripting languages and the cmd prompt. I don't think the application that reads the web.config file is smart enough to translate %ProgramFiles% to the proper file path, and if it did, you need to see if it adds the final slash to the end of the path. You still have to code the database name to make it work. Since it's on your hard drive, a trusted connection should work fine.

                              Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;
                              Trusted_Connection=Yes;

                              [Edit] If you need connection strings, go here http://www.connectionstrings.com/[^] Richard, I was talking to the OP, still getting use to the new look and feel.

                              L 1 Reply Last reply
                              0
                              • J jkirkerx

                                I think this is what your looking for. Your example makes no sense to me, and I don't see the point of it. If your sql server is loaded on your hard drive, why not use the standard connection string? As far as using a programmable path like %ProgramFiles%, that's a Windows thing, which works in certain scripting languages and the cmd prompt. I don't think the application that reads the web.config file is smart enough to translate %ProgramFiles% to the proper file path, and if it did, you need to see if it adds the final slash to the end of the path. You still have to code the database name to make it work. Since it's on your hard drive, a trusted connection should work fine.

                                Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;
                                Trusted_Connection=Yes;

                                [Edit] If you need connection strings, go here http://www.connectionstrings.com/[^] Richard, I was talking to the OP, still getting use to the new look and feel.

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #17

                                jkirkerx wrote:

                                I was talking to the OP

                                And you did it correctly.

                                One of these days I'm going to think of a really clever signature.

                                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