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. database directory bug?

database directory bug?

Scheduled Pinned Locked Moved C#
helpdatabasequestion
8 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    i use this string to connect on my database conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source= myDatabase.mdb;"; the problem is i consider my database is in the same directory of the main .exe infact at the first time it find the database, but if i call an openDialog form to load some file it moves the current directory path at the path of the file loaded in the openDialog... So if i try to reconnect at my database it find nomore the source .mdb . How could i handle this bug?

    D C 2 Replies Last reply
    0
    • A Anonymous

      i use this string to connect on my database conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source= myDatabase.mdb;"; the problem is i consider my database is in the same directory of the main .exe infact at the first time it find the database, but if i call an openDialog form to load some file it moves the current directory path at the path of the file loaded in the openDialog... So if i try to reconnect at my database it find nomore the source .mdb . How could i handle this bug?

      D Offline
      D Offline
      David Salter
      wrote on last edited by
      #2

      Its not a bug, the current working directory has been changed by the file open dialog so the current working directory is no longer that of your application hence you can't see the database. You need to give the full path to your database. You should be able to get the path of your exe, and then append the database name on to the end of it, so wherever you app is installed it will always work.


      Database FAQ

      A 1 Reply Last reply
      0
      • D David Salter

        Its not a bug, the current working directory has been changed by the file open dialog so the current working directory is no longer that of your application hence you can't see the database. You need to give the full path to your database. You should be able to get the path of your exe, and then append the database name on to the end of it, so wherever you app is installed it will always work.


        Database FAQ

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        How can i get the path of my .exe on running?

        M D 2 Replies Last reply
        0
        • A Anonymous

          How can i get the path of my .exe on running?

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

          ApplicationDirectory.Directory Property Mazy
          "One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji

          A 1 Reply Last reply
          0
          • A Anonymous

            How can i get the path of my .exe on running?

            D Offline
            D Offline
            David Salter
            wrote on last edited by
            #5

            Have a look at the Application.ExecutablePath property.


            Database FAQ

            A 1 Reply Last reply
            0
            • M Mazdak

              ApplicationDirectory.Directory Property Mazy
              "One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji

              A Offline
              A Offline
              Anonymous
              wrote on last edited by
              #6

              How can i use it i'm unable... i've tryed with: mPathExe = ApplicationDirectory.Directory; but it is not correct couse i have to create a class as: ApplicationDirectory myExe = new ApplicationDirectory(XXXXXXX); At the place of XXXXXXX i have to give the path of the exe!!! BUT i need to know it before! :(

              1 Reply Last reply
              0
              • D David Salter

                Have a look at the Application.ExecutablePath property.


                Database FAQ

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                Perfect

                1 Reply Last reply
                0
                • A Anonymous

                  i use this string to connect on my database conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source= myDatabase.mdb;"; the problem is i consider my database is in the same directory of the main .exe infact at the first time it find the database, but if i call an openDialog form to load some file it moves the current directory path at the path of the file loaded in the openDialog... So if i try to reconnect at my database it find nomore the source .mdb . How could i handle this bug?

                  C Offline
                  C Offline
                  Charlie Williams
                  wrote on last edited by
                  #8

                  The FileDialog class (from which OpenFileDialog is derived) has a RestoreDirectory property that if set to true will direct the dialog to restore the current directory before closing. Charlie if(!curlies){ return; }

                  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