Migrating legacy applications written VBA or VB 6.0 to modern operating systems can frequently cause a headache.
Symptoms
I ran into one such instance with a FactoryTalk View SE Application that used VBA to connect to a SQL database. Data Access Objects (DAO) and ODBCDirect was used to create the ODBC connection and iterate over a Batch Client Cursor record set. The old application was running on Windows Server 2003 and I was porting it to Windows Server 2012 R2.
The following code was used:
Set ODBCWorkSpace = CreateWorkspace("NewODBCWorkspace", "SQLUser","passw0rd!",dbUseODBC)
ODBCWorkSpace.DefaultCursorDriver = dbUseClientBatchCursor
strDBConn = "ODBC;Database = dbName;UID=SQLUser;PWD=passw0rd!;DSN=ODBCDSN"
Set RecipeConn = ODBCWorkSpace.OpenConnection("", dbDriverNoPrompt, False, strDBConn)
ODBCWorkSpace.DefaultCursorDriver = dbUseClientBatchCursor
strSQL = "select * from Table"
Set rstQuery = RecipeConn.OpenRecordset(strSQL, dbOpenDynamic, 0, dbOptimisticBatch)
When running it I received the following error:
This was due to not having Data Access Objects installed on the 2012 R2 server.
The next errors are below, they were caused by not having the appropriate DLL for the Batch Client cursor.
Resolution
- Download Service Pack 6 for Visual Basic 6.0 (Vs6sp6.exe)
Service Pack 6 for Visual Basic 6.0 - Run Vs6sp6.exe and extract the files
- Open
msrdo20.cab
, it contains the following files:MSRDO20.DLL
,MSRDO20.INF
, andRDOCURS.DLL
. Extract all three files and copy them to theC:\Windows\Sys64WOW\
directory. - Open an elevated command prompt, navigate to C:\Windows\Sys64WOW, and register
MSRDO20.DLL
. TheRDOCURS.DLL
does not need to be registered.
C:\Windows\System32> cd C:\Windows\Sys64WOW
C:\Windows\Sys64WOW> regsvr32 MSRDO20.DLL