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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Relative path of database?

Relative path of database?

Scheduled Pinned Locked Moved C#
databasehelpquestion
6 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.
  • F Offline
    F Offline
    fahiemulleh
    wrote on last edited by
    #1

    Hi all. I have a separate class for connection manager. I have given ABSOLUTE PATH HERE like c:\simple\abc.mdf. I want to make it relative. I have tried the following but doesn't work: "..\simple\abc.mdf". Please help me. I will be very thankful to you.

    N E 2 Replies Last reply
    0
    • F fahiemulleh

      Hi all. I have a separate class for connection manager. I have given ABSOLUTE PATH HERE like c:\simple\abc.mdf. I want to make it relative. I have tried the following but doesn't work: "..\simple\abc.mdf". Please help me. I will be very thankful to you.

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      The path depends on what it is relative to. Where is the application that is using it located?


      only two letters away from being an asset

      F 1 Reply Last reply
      0
      • N Not Active

        The path depends on what it is relative to. Where is the application that is using it located?


        only two letters away from being an asset

        F Offline
        F Offline
        fahiemulleh
        wrote on last edited by
        #3

        I have a folder abc. In abc, i have following things placed: Simple(Folder) , simple.sln, simple.suo and database.mdf. In Simple Folder, i have all classes, bin, web references etc. So please tell me what will be the relative path in my case? Please help me in this regard.

        N 1 Reply Last reply
        0
        • F fahiemulleh

          I have a folder abc. In abc, i have following things placed: Simple(Folder) , simple.sln, simple.suo and database.mdf. In Simple Folder, i have all classes, bin, web references etc. So please tell me what will be the relative path in my case? Please help me in this regard.

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Your exe is compiled and placed in the bin/debug or bin/release folder for a Wundows app. When setting the connection string for your database file it needs to be relative to this location.


          only two letters away from being an asset

          B 1 Reply Last reply
          0
          • N Not Active

            Your exe is compiled and placed in the bin/debug or bin/release folder for a Wundows app. When setting the connection string for your database file it needs to be relative to this location.


            only two letters away from being an asset

            B Offline
            B Offline
            Bob Nadler
            wrote on last edited by
            #5

            Or use Path.Combine(Application.StartupPath,"relative_path"). This will always work as long as relative_path is in the same directory as your executable.

            1 Reply Last reply
            0
            • F fahiemulleh

              Hi all. I have a separate class for connection manager. I have given ABSOLUTE PATH HERE like c:\simple\abc.mdf. I want to make it relative. I have tried the following but doesn't work: "..\simple\abc.mdf". Please help me. I will be very thankful to you.

              E Offline
              E Offline
              elitehuang
              wrote on last edited by
              #6

              AS i know:the path "..\simple\abc.mdf" which must exist under the project bin directory.otherwise it cann't be found by project. maybe you can set a proprity for path which to get the path of file and then to deal with it.

              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