Results 1 to 2 of 2

Thread: [02/03] Storing App Location

  1. #1

    Thread Starter
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    [02/03] Storing App Location

    I created an mdi application that manages it's own Access database. I noticed that I couldn't use Environment.CurrentDirectory to locate the database at runtime because the use of SaveFileDialogBoxes changes the current directory. I got around this by using a ReadOnly constant in the parent form and then referenced from the child forms. Like this:

    Parent
    Code:
    Public ReadOnly mdbLocation As String = Environment.CurrentDirectory & "\am090506.mdb;"
    Child
    Code:
    Dim parForm As New uiMainForm
        Dim appLoc As String = parForm.mdbLocation
    ...Which later uses like this:
    Code:
    Dim bomConString As String = _
                    "Provider=Microsoft.Jet.OLEDB.4.0;Data " & _
                    "Source=" & appLoc & _
                    "Jet OLEDB:Database Password=*****;"

    The problem I immediately see from doing it this way is the memory usage because I will have two instances of the parent form open all the time (Every child form uses the database). Is there a better way of doing this?
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  2. #2
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [02/03] Storing App Location

    VB Code:
    1. Application.StartupPath

    Gets the path for the executable file that started the application, not including the exicutable name.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

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