1

I am running into a weird situation, hoping someone here can help.

I am communicating to a MySQL database using 'MySQL ODBC 5.1 Driver', although the below code works fine when run separately on a .vbs file, when i put the same in HTA i get Error

Error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I put the same code in a .vbs file and run the VBS file via an HTA using objShell.run command still the same problem.

When the VBS file is run independently or via CMD it runs fine displaying the contents. Any ideas ?

Call Query    
Sub Query
        Set objFSO  = CreateObject("Scripting.FileSystemObject")
        Set objConnection = CreateObject("ADODB.Connection") 
        Set objRecordSet = CreateObject("ADODB.Recordset") 

                adOpenStatic = 3 
                adLockOptimistic = 3 


                objConnection.Open _ 
                    "Driver={MySQL ODBC 5.1 Driver};Server=[Some Address];Database=bldb;User=usr;Password=pass;" 

                objRecordSet.Open "SELECT * FROM Clients Where Machine Like 00000" & , _ 
                        objConnection, adOpenStatic, adLockOptimistic 

                Do While Not objRecordSet.EOF
                    Company = objRecordSet (1)
                    Contact = objRecordSet (2)
                    Phone   = objRecordSet (3)
                    objRecordSet.MoveNext
                Loop

                objRecordSet.Close
                objConnection.Close
                Set objRecordSet=Nothing
                Set objConnection=Nothing

    End Sub
Telson Alva
  • 842
  • 6
  • 22
  • 37
  • Probably working directory is different in HTA and VBS. Please see [this answer](http://stackoverflow.com/a/14744253/1169519). – Teemu Feb 05 '14 at 05:33

1 Answers1

2

I was able to figure this on, the problem was the 32/64 Bit nature of HTA and the ODBC Driver.

I had installed a 64Bit ODBC driver and my HTA was running as a 32Bit Application.

Either run %Windrir%\System32\mshta.exe or install the the 32Bit Driver.

I chose to install the 32Bit variant of the MySQL ODBC Driver which resolved the problem.

Telson Alva
  • 842
  • 6
  • 22
  • 37