Results 1 to 7 of 7

Thread: Database Location Hardset?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    Arkansas
    Posts
    28
    I have a program that I have written in VB6. My problem is this, when others install the program it looks to my hard drive on the network for the database because in the prog it is hard set. How do I fix this problem? What I want to be able to do is install the prog into any folder and as long as the db file is in the same folder it should start up.

  2. #2
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Might I suggest app.path

    Hi,
    Try using app.path. Sounds like what you need.

    Check out this code:

    Code:
    Sub FindDBPath
    
    dim sDBPath as string
    
        If right$(app.path, 1) = "\" then
           sDBPath = app.path & "your database name here"
        Else
           sDBPath = app.path & "\your database name here"
        End IF
    
    End Sub
    Hope that helps.

    Jazzbass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    Arkansas
    Posts
    28
    Thanks for the code. I only have one more question. . .where shoud I insert this code at? Anywhere I have an adodc?

  4. #4
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Talking Pretty much anywhere

    Your welcome for the code,

    As to you question:

    Well, it depends. Do you have a routine that finds Public variables when you program is first open. I use this code in all of my programs that require some sort of file use.

    You could put it at every place you ADO, but what I would do is paste the above code into a module and declare the variable sDBPath as Public in the General Declarations of the Module.

    I know some here do not like to use Public Variables, but I do and seem to work fine for me.

    Anymore ?'s, please ask.

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    Arkansas
    Posts
    28
    I created a new module and inserted the code like you said. I am still having this problem though. I have several screens in my program, each one has an Adodc in it. On each one of the Adodc's there is a Connection String that looks to the database. How can I make it not look to the database and look to the module? Also, in your code where it says "your database name here" should I just put. . . eiss.mdb (this is the name of my Db); or should I put the final destination of the file?

  6. #6
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393
    OK,

    I'm sorry. I left something out.


    "Your Database Here" Question,

    Yes replace this with the name of your database


    To Find the location of the database


    When your first form loads, under the Form_Load event, call the sub like this.

    Code:
    FindDBPath
    Make sure your variable sDBPath is Declared Public in the Genernal Declarations of your module.

    Now, in your connection string, for the path and name of your database, just put in "sDBPath" without the quotes.
    Repeat this for all connections you need to make.

    Since you ran the Sub FindDBPath right when your program starts, this variable will be avaliable anywhere in your program.

    Make sure when you exit your program, before the "End" command, type in this code.

    Code:
    sDBPath = ""
    Whatever memory this variable takes up, is now free.

    Hope I explained it OK. If you need further help, post you code and make changes if you would like.

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  7. #7
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Smile I'm Leaving

    greysquirl,

    Just wanted to let you know I'm leaving for the day and I won't be able to check the board until tomorrow.

    Hope the help is what you needed.

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width