question

echoScout avatar image
echoScout asked

sp_OACreate vbscript.regexp Class not registered

Imagine a Windows Server 2003 Enterprise x64 Edition. I can create a 'vbscript.regexp' object using a vbscript (confirming that the DLL is registered). I cannot create a 'vbscript.regexp' object using sp_OACreate in a SQL Server 2005 SP3 (.4053)(cluster) environment. OLE Automation is checked ON in surface area configuration. The sp_OACreate was working until very recently. Can you help me? ****CODE**** declare @source varchar(5000), @regexp varchar(1000), @replace varchar(1000), @globalReplace bit, @ignoreCase bit set @source = 'NBG76TF43' set @regexp = '[^0-9]' set @replace = '' set @globalReplace = 1 set @ignoreCase = 1 DECLARE @hr integer DECLARE @objRegExp integer DECLARE @result varchar(5000) EXECUTE @hr = sp_OACreate 'VBScript.RegExp', @objRegExp OUTPUT IF @hr <> 0 BEGIN EXEC @hr = sp_OADestroy @objRegExp PRINT 'A' PRINT @hr END EXECUTE @hr = sp_OASetProperty @objRegExp, 'Pattern', @regexp IF @hr <> 0 BEGIN EXEC @hr = sp_OADestroy @objRegExp PRINT 'B' PRINT @hr END EXECUTE @hr = sp_OASetProperty @objRegExp, 'Global', @globalReplace IF @hr <> 0 BEGIN EXEC @hr = sp_OADestroy @objRegExp PRINT 'C' PRINT @hr END EXECUTE @hr = sp_OASetProperty @objRegExp, 'IgnoreCase', @ignoreCase IF @hr <> 0 BEGIN EXEC @hr = sp_OADestroy @objRegExp PRINT 'D' PRINT @hr END EXECUTE @hr = sp_OAMethod @objRegExp, 'Replace', @result OUTPUT, @source, @replace IF @hr <> 0 BEGIN EXEC @hr = sp_OADestroy @objRegExp PRINT 'E' PRINT @hr END EXECUTE @hr = sp_OADestroy @objRegExp IF @hr <> 0 BEGIN PRINT 'F' PRINT @hr END PRINT @result /* A -2147211480 B -2147211480 C -2147211480 D -2147211480 E -2147211480 F -2147211480 */
sql-server-2005automationregex
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Usman Butt avatar image
Usman Butt answered
Is there any environment change like from 32 bit to 64 bit? Normally, This problem occurs because Microsoft does not support creating an OLE object from a 32-bit COM DLL in an x64 edition of SQL Server 2005. To work around this problem, use a 64-bit compiler to recompile the COM DLL. Please let us know if this solves your problem.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.