-
Feb 17th, 2018, 06:35 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Very strange behaviour of App.Path
Hello VBForums experts
A strange behaviour of App.Path is driving me mad.
This is my small application after compilation and installation
This is my connection string.
In a module:
Code:
Public MyDBPath As String
in Sub Main
Code:
MyDBPath = App.Path & "\Vdata.mdb"
In the form
Code:
Public Sub connect()
Set DB = New ADODB.Connection
Set RS = New ADODB.Recordset
DB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MyDBPath & ";Persist Security Info=False;Jet OLEDB:Database Password=123456"
RS.CursorLocation = adUseClient
End Sub
I also tried with the following:
Code:
Public Sub connect()
Set DB = New ADODB.Connection
Set RS = New ADODB.Recordset
DB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database password=123456; Data Source=" & App.Path & "\Vdata.mdb"
RS.CursorLocation = adUseClient
End Sub
According to this string, the database is supposed to be in the same folder as the exe file.
Unfortunately the program seem not taking this into account.
Because even if I delete the Vdata.mdb from the App.Path, the program is working fine.
I wonder which Vdata.mdb my program is using since the one in the App.Path is deleted.
I checked the existence of the files.
Code:
MsgBox App.Path & IIf(Right$(App.Path, 1) <> "\", "\", "") & App.EXEName & ".exe"
I get the full path of the program.
Code:
If Dir(App.Path & "\Vdata.mdb") <> vbNullString Then MsgBox "yes"
the msgbox returns yes.
-
Feb 17th, 2018, 07:07 AM
#2
Re: Very strange behaviour of App.Path
My crystal ball says that your program is installed somewhere below the Programs folder, does not have Admin privileges, is not manifested "as invoker" and so Vdata.mdb has been virtualized. Right? If you search for Vdata.mdb you'll find it somehwere below AppData\Roaming IIRC.
Move your Vdata.mdb to a folder where the program actually got write permissions (real ones, not virtual).
Wolfgang
-
Feb 17th, 2018, 07:36 AM
#3
Thread Starter
Fanatic Member
Re: Very strange behaviour of App.Path
Thank you sir
I installed the application in the partition D and it is recognizing the App.Path.
This means I can't install the application under the Programs folder?
-
Feb 17th, 2018, 08:03 AM
#4
Re: Very strange behaviour of App.Path
Originally Posted by samer22
This means I can't install the application under the Programs folder?
Not as long as your program tries to write to a folder it doesn't have write permission for; this applies, among others, to the Programs folder and its subfolders.
Files like Access databases or INI files which the program attempts to write to should be placed in a separate, non-protected folder.
Clarification: App.Path works correctly under all circumstances; the problem is that with virtualisation in effect Windows does not use this path but silently works with a copy of the file located somewhere else.
HTH Wolfgang
Last edited by Wolfgang Enzinger; Feb 17th, 2018 at 08:10 AM.
Reason: typo corrected, some clarification
-
Feb 17th, 2018, 08:15 AM
#5
Re: Very strange behaviour of App.Path
Originally Posted by samer22
This means I can't install the application under the Programs folder?
You can install the application under the Programs folder.
But Vdata.mdb must be located somewhere else, and your application modified to point to that 'somewhere else'.
-
Feb 17th, 2018, 09:54 AM
#6
Thread Starter
Fanatic Member
Re: Very strange behaviour of App.Path
Thank you very much
I understand now
Just a question out of curiosity:
Is there a way to find the Vdata.mdb file with which the program is working?
I looked in the roaming folder but there is no file with the name of Vdata.mdb
thank you
-
Feb 17th, 2018, 10:32 AM
#7
Re: Very strange behaviour of App.Path
Originally Posted by samer22
Is there a way to find the Vdata.mdb file with which the program is working?
I looked in the roaming folder but there is no file with the name of Vdata.mdb
thank you
The folder is named VirtualStore and you can find it in
C:\Users\[username]\AppData\Local\VirtualStore\
-
Feb 17th, 2018, 11:47 AM
#8
Thread Starter
Fanatic Member
Re: Very strange behaviour of App.Path
gibra
You are great
yes It is there
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|