1️⃣ ODBCAD32 (64-bit) vs ODBCAD32 (32-bit)
64-bit version: Located at
C:\Windows\System32\odbcad32.exe
➤ Manages 64-bit DSNs—not usable by VB6 apps.32-bit version: Located at
C:\Windows\SysWOW64\odbcad32.exe
➤ Manages 32-bit DSNs—required for VB6, which is 32-bit.
✅ Always use the 32-bit ODBC Administrator for VB6 compatibility.
2️⃣ User DSN vs System DSN
User DSN: ➤ Stored per user in
HKEY_CURRENT_USER
. ➤ Only visible to the user who created it. ➤ Can access mapped drives likeG:
.System DSN: ➤ Stored in
HKEY_LOCAL_MACHINE
. ➤ Visible to all users. ➤ Requires admin rights to create/edit. ➤ Cannot see mapped drives unless created in same session.
⚠️ If both exist with the same name, User DSN takes priority.
3️⃣ Logical Drive vs UNC Path
Mapped drives (e.g., G:): ➤ Session-specific; may disappear in elevated/admin mode. ➤ Not reliable for System DSNs.
UNC paths (e.g.,
\\Server\Share\YourDB.mdb
): ➤ Always accessible across sessions and users. ➤ Recommended for both System DSNs and DSN-less connections.
🛠️ Use Registry Editor to manually set
DBQ
to a UNC path if the GUI doesn’t allow it.
🛠️ Manually Setting DBQ
to a UNC Path in the Registry
When the ODBC Administrator (odbcad32.exe
) doesn't allow UNC paths in the Select Database dialog, you can manually set the database path by editing the registry.
📍 Registry Location for System DSNs (32-bit):
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ODBC\ODBC.INI\YourDSNName
🔧 Steps:
Open Registry Editor (
regedit.exe
) as Administrator.Navigate to the key above, replacing
YourDSNName
with the name of your DSN.In the right-hand pane, look for a string value named
DBQ
.If it doesn’t exist, right-click → New > String Value → name it
DBQ
.
Double-click
DBQ
and enter your full UNC path:Code\\ServerName\ShareName\YourDatabase.mdb
Close Registry Editor.
✅ Why This Works
The
DBQ
value tells the Access ODBC driver where to find the.mdb
file.UNC paths are session-independent and work reliably across users and privilege levels.
This bypasses the GUI limitation and ensures your VB6 app can connect without relying on mapped drives.
沒有留言:
張貼留言