Click to See Complete Forum and Search --> : Tracking Access Database after Installation
Lloyd
Jun 9th, 1999, 11:26 AM
How can I have VB6 to keep track of the path for a Access Database after installation of a program?
I would apperciate any help!
Lloyd
NMahon
Jun 13th, 1999, 07:40 PM
you need to modify the setup1 project, and then recompile Setup1.exe - before building you distribution set (cab files etc).
In VB open the setup1 project. open form : 'frmSetup1'. Go to code window.
In the Form_Load event, after 'gstrFontDir' add following code:
'********************************************
'Save information to the Registery
Dim strSrcDrv As String 'Source Drive Letter
Dim strDstDrv As String ' Destination Drive Letter
Dim strDstPth As String ' Destination Path
Dim strDstDrvPth As String
strDstDrv = UCase(Left(gstrDestDir, 1))
strDstPth = UCase(Mid(gstrDestDir, 4))
SaveSetting appname:="MyApp", section:="Drives", Key:="MyDatabase", setting:=strDstDrv & ":\" & strDstPth & "Mydatabase.mdb"
'********************************************
If you include the database in the list of files (package & deployment wiz), the above code will ensure that the registry stores the location of the mdb.
In your program, you will need to use GetSetting, to re-connect data-controls to correct path.
Above does not cater for users moving databases from installation path. So, add a function like:
Private Function FileExists(FileName) As Boolean
'This function designed to Test for exisitience of all databases required
On Error GoTo FileNameErr
FileExists = (Dir(FileName) <> "")
Exit Function
FileNameErr:
MsgBox "The program needs to be reinstalled - it cannot find the database files needed at :' " & FileName & " '. The program will now terminate."
End Function
...where FileName is name of database - retrieved from the registry.
Good Luck
Lloyd
Jun 14th, 1999, 10:16 PM
Thanks I apperciate the help!!!!!!!!
Lloyd
ruaVB2?
Apr 23rd, 2004, 01:09 PM
NMahon I'm lost.....
you say "In VB open the setup1 project. open form : 'frmSetup1'. Go to code window.
In the Form_Load event, after 'gstrFontDir' add following code:"
How do you open setup1 which is an exe?
If you mean my project file . . . I don't have 'frmSetup1' . . .
pleeze enlighten me
RobDog888
Apr 24th, 2004, 03:08 PM
Wouldn't it be easier to modify the path in the P&D wizard when
your are packaging it? Just enter an additional subdirectory or
just put it in any on the dropdown selection path macros like
apppath or programfiles.
Then when your program starts you can populate your
connection string with that path. Ex. app.path.
http://www.vbforums.com/attachment.php?s=&postid=1677052
HTH
damica
Apr 24th, 2004, 05:14 PM
Here's an Idea that I use.
Some of the times the end user needs to, or wants to, place the database where they want it to be.
So I create an .INI file that store's the locations of the database and have my program read the .INI file. This way they can change it when ever they need to and your program will always know the location.
This is just one of the means that I use. You may wish to do other wise.
RobDog888
Apr 24th, 2004, 07:04 PM
Yes, I have used that method also, but I think they are talking
about the first run of the program after its installed. They want to
know how to determine the location of the db for the first time.
:)
ruaVB2?
Apr 26th, 2004, 11:10 AM
Thanx for the ideas guys . . .we're headed in the right direction. But maybe I'm doing things backwards and you have a better way.
I package an MDB file with my app, if the person reinstalls then I don't want the package to overwrite the existing database just simply update the exe.
I know I can write two packages, one with mdb and one without mdb and have person select his download preference.
But, I was thinking of having just one package including mdb and have the installation program query the user if he'd like to keep his existing database or overwrite it during the installation process.
Any ideas?
RobDog888
Apr 26th, 2004, 11:15 AM
First thing that comes to mind is to alter the setup1.vbp and
compile a new setup project. Add a form in there to designate
installing a new database or have them browse to the location of
an existing one.
HTH
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.