CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2007
    Posts
    51

    VB6 - Locate/Access Database in a Server directory



    Hi everyone,
    I am attempting to access a database that is located in a shared server/ directory "K:\". Assuming I don't know where the database is located, how can I programatically tell vb to locate this database by searching all the network server directories?

    My database name is called:
    Code:
    PTS.mdb
    Currently I copied the database into my local drive for testing purposes.
    Code:
    "C:\PTS.mdb"

    This is how I'm accessing the database now:
    Code:
    Dbpath = "C:\" 
    DbName = "PTS" 
    
    Set Db = OpenDatabase(Dbpath & DbName)
    Any input will be greatly appreciated.
    Thanks.
    GiftX

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6 - Locate/Access Database in a Server directory

    You are going to have to let the user choose it the first time, and then save it somewhere so it can be loaded automatically.

    There's no way you can 'find' a db. You wouldn't have permission probably.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2007
    Posts
    51

    Re: VB6 - Locate/Access Database in a Server directory

    Hi dg.
    That's not really the case here. The database is in a centralized location and everyone can point to it and access it from their workstation.

    For example, this is the location of my department's database which is hard code in my module:
    Code:
    \\515opsisdallf00008\SHARED\PyrlApps\PTSprod\PTS.mdb
    Suppose I don't know the part, how do I search/locate this database?

    Thanks.
    tgif

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB6 - Locate/Access Database in a Server directory

    You know this: \\515opsisdallf00008\SHARED\
    and the db name that you are looking for?

    You could write an app to search recursively all the folders on that share, but, as I said, there may be permission issues, or duplicates.
    Last edited by dglienna; November 19th, 2007 at 04:46 PM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jul 2004
    Location
    Jakarta, Indonesia
    Posts
    596

    Re: VB6 - Locate/Access Database in a Server directory

    i think u can't do something like that..u'll end up searching entire network..

    Suppose I don't know the part, how do I search/locate this database?
    maybe what u ask is instead changing the DBPath inside the program, u want it to be dynamic so u don't need to re-coding it again?

    u can use .INI file as external file so if the Path is changing, u only changing the .INI file

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL

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

Featured