CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    File Location at Design/Run Times

    I'm relatively new to the VB development world but have extensive C++ development experience. I seem to be having a problem with the location of an Access Database when I run the program. I had the full pathname in the DatabaseName property of a Data Control but when I copied all files to a "Temp" directory to experiment with an idea, errors popped up stating that it was unable to locate <path>\MyFile.mdb at startup. Since I'll not know where the end user will be installing the application files, I attempted to circumvent this by only entering MyFile.mdb without success. I also tried .\MyFile.mdb with the same error(s). Could someone let me know if I'm doing something wrong?

    Thanx, Chris.


  2. #2
    Join Date
    Jan 2000
    Posts
    7

    Re: File Location at Design/Run Times

    Chris.

    This is a very common issue. Users are very unpredictible. The best way to deal with this situation is to not use properties (design time) to set your database location. Do it in run time and use variables. IE. data1.databasename = G_Datafilename. The info for the variable is stored in a text file(ini) on the users machine and is modified when the user installs the program. This way you know exactly where the database is.

    An easier way: Data1.databasename = App.path & "\mydatabase.mdb" The caveat here is that the database MUST always be in the same path as the exe.

    Hope this has helped,

    Joe B. Lively


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