1

As SQL DMO is deprecated now, I need to modify the below line in a javascript file to create SQL SMO automation object in Javascript using ActiveXObject :

var sql;
sql = new ActiveXObject("SQLDMO.SQLServer");

The above snippet is throwing Automation server can't create object.

The client system where this is running has SQL server 2014. I tried the below but the got the same error :

var sql;
sql = new ActiveXObject("Microsoft.SqlServer.Management.Smo.Server");

I also checked whether my system has SQL SMO installed or not in PowerShell :

[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")

I got the location of Microsoft.SqlServer.Smo.dll as output: C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Smo\12.0.0.0__89845dcd8080cc91

Please help me in creating the automation object using SQL SMO.

scott_lotus
  • 2,977
  • 19
  • 43
  • 66

1 Answers1

0

It looks like you might have to use RegAsm to expose the .Net interface to COM.

http://www.progtown.com/topic336324-to-createnet-object-from-simple-jscript.html

Bruce Dunwiddie
  • 2,741
  • 1
  • 13
  • 19
  • Sorry to say that, I saw this link earlier also, but not sure what exactly needs to done here. – user3239969 Feb 10 '16 at 19:07
  • I registered Microsoft.SqlServer.Smo.dll manually using RegAsm.exe and check again. Got the same error again. – user3239969 Feb 10 '16 at 20:23
  • http://stackoverflow.com/questions/24451812/how-to-do-regasm-so-that-it-cover-32-bit-and-64-bit . Sorry, but it's just going to require step by step troubleshooting. You're doing something non standard so there's not a well defined path documented anywhere online that I'm seeing. – Bruce Dunwiddie Feb 10 '16 at 20:42
  • When you say non-standard, is there any other way of doing it wih Javascript. I know it can be done via Powershell. But i dont want to change my whole script for this. Please suggest if there are other ways. – user3239969 Feb 11 '16 at 09:12
  • Doing it in JavaScript that requires an ActiveX interface to COM is non-standard and legacy. Powershell would be the standard way. – Bruce Dunwiddie Feb 11 '16 at 15:35