sql server - Enabling filestream with WMI and C# -
i have need enable filestream on sql server through program. according documentation have found, can done through wmi following code:
set fsinstance = getobject("winmgmts:\\" & machinename & "\root\microsoft\sqlserver\computermanagement10:filestreamsettings='" & instancename & "'") set method = fsinstance.methods_("enablefilestream") set inparam = method.inparameters.spawninstance_() inparam.accesslevel = targetlevel inparam.sharename = sharename set outparam = fsinstance.execmethod_("enablefilestream", inparam)
converting c#, following:
managementclass mc = new managementclass(new managementscope(@"\\.\root\microsoft\sqlserver\computermanagement10"), new managementpath("filestreamsettings"), new objectgetoptions(new managementnamedvaluecollection() { {"instancename", "mssqlserver"} })); managementbaseobject inparams = mc.getmethodparameters("enablefilestream"); inparams["accesslevel"] = 1; inparams["sharename"] = "alliance"; mc.invokemethod("enablefilestream", inparams, null);
whenever try this, though, throws exception on invokemethod. message "invalid method parameter(s)". have attempted remove 2 lines set accesslevel , sharename , run way, same exception. doing wrong here?
Comments
Post a Comment