Friday, January 15, 2010

DSN Drudgery

When creating a DSN on a 64 bit OS you must have a 64 bit ODBC driver. In absence of this driver you will need to create your DSN in the 32 bit ODBC manager and not the one located in the 'Control Panel.'

You can find the 32 bit ODBC client at the following path (At least on Windows 7):

C:\Windows\SysWOW64\odbcad32.exe

After you set up your ODBC connection in this application you would assume that everything will work fine from here on out. This is true for applications like MS Access. However, any vbscript that accesses a DNS will fail with an error message similar to the following:



At first glance this message may lead you to believe that you've mistakenly set up the ODBC connection in the 64 bit ODBC manager. As it turns out the reality of the situation is that by default the csript.exe or wscript.exe script handlers only look at the 64 bit ODBC connections.

In order to allow your vbscript to access a 32 bit DSN you will be required to run your program using the 32 bit cscript.exe or wscript.exe executables and thus you must run your vbscript in the following manner:


C:\Windows\SysWOW64\wscript.exe C:\script_location\script_name.vbs

After launching the specified command if you look in the 'Task Manager' you will clearly see that the script is running in the context or 'Windows on Windows' or perhaps better stated at the 32 bit application layer. This is demonstrated below.


I hope this saves someone the frustration that I went through.