database directory bug?
-
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?
-
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?
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.
-
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.
-
-
ApplicationDirectory.Directory
Property Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - BabujiHow 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! :(
-
-
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?
The
FileDialog
class (from whichOpenFileDialog
is derived) has aRestoreDirectory
property that if set to true will direct the dialog to restore the current directory before closing. Charlie if(!curlies){ return; }