Migrating legacy applications written VBA or VB 6.0 to modern operating systems can frequently cause a headache.
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.
- 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
msrdo20.cab, it contains the following files:
RDOCURS.DLL. Extract all three files and copy them to the
- Open an elevated command prompt, navigate to C:\Windows\Sys64WOW, and register
RDOCURS.DLLdoes not need to be registered.
C:\Windows\System32> cd C:\Windows\Sys64WOW C:\Windows\Sys64WOW> regsvr32 MSRDO20.DLL