Hello all,
I have created a pharmacy application in vb6, i packaged that, itselt has an access database. it works well in my pc, but when i want to send it to another computer, it installs there but dose'nt work there and says: C:// desktop/main/pharmacy.mdb is not a valid path, make sure you have spelled the path name correctly..., What is the problem? my package has all the files needed for the setup, but it dose'nt work. i know this is an old topic, but i really need it, Please help me.

Dani AI

Generated

Short answer: the app on the target PC is still being asked to open the MDB from your development path, so something in the shipped package or the database itself contains that absolute path. Common causes are hardcoded connection strings, linked tables inside the Access file, an ODBC DSN, or a saved registry/INI value — not a bug in App.Path.

What to check (short checklist):

  • Verify where the installer actually put pharmacy.mdb on the target machine (open the install folder and note the full path).
  • Compare that path to the exact path shown in the error. If the error references your dev path, search your project files for that literal string (search every .frm, .bas, .cls, .vbp and any shipped INI/registry entries).
  • Open the MDB in Access on your dev PC and inspect Linked Tables (Linked Table Manager). If the front-end was linked to a back-end at C:\desktop\main\pharmacy.mdb, the front-end will keep trying to open that exact path on any machine. Relink links to the shipped location or relink at first-run in code.
  • Check for ODBC DSNs or a DSN-based connection string on the target PC; prefer DSN-less connections so the app controls the path.

Small, safe VB6 helper to build the runtime path (use this instead of hardcoded strings):

Private Function GetDBFullPath() As String
    Dim basePath As String
    basePath = App.Path
    If Right$(basePath, 1) <> "\" Then basePath = basePath & "\"
    GetDBFullPath = basePath & "data\pharmacy.mdb"
End Function

Add a short debug step at startup (show or log the path your app will use) to confirm the runtime path on the installed machine.

Packaging and permissions notes: the VB6 PDW often installs files under Program Files, which is not writable by normal users — Jet/Access creates an .ldb lock file and needs write access. If the DB must be written, install it to a writable location (for example ProgramData or a per-user AppData folder) or change installer ACLs. As suggested, avoid hardcoding; additionally, check linked tables and installer file locations — those are the usual culprits that cause the app to keep pointing back to the developer PC.

Recommended Answers

All 5 Replies

Sir, i have also the same problem

do not hardcode your database path.

Just make your setup structure like this:

App.exe (your compiled app)
database\db.mdb (your database)

Then on your code where you connect to database, you can do it like this:
App.path & "\database\db.mdb"

thats it. hope it helps.

thanks jhai,
but still when i want to install my setup in another pc it still says: This is not a valid path. that path belongs to my pc.

i made it through package and deployment software, yeah i am sure all the files are included, but i think the problem is at app.path, when i install the software in any other pc, it shows me my own pc path. i did'nt understand your code snippet link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.