解决方法
[CustomAction] public static ActionResult FillServerInstances(Session xiSession) { xiSession.Log("Begin CustomAction"); xiSession.Log("opening view"); View lView = xiSession.Database.OpenView("DELETE FROM ComboBox WHERE ComboBox.Property='DBSRVR'"); lView.Execute(); lView = xiSession.Database.OpenView("SELECT * FROM ComboBox"); lView.Execute(); int Index = 1; bool flag = false; try { foreach (DaTarow dr in Microsoft.sqlServer.Management.Smo.SmoApplication.EnumAvailablesqlServers(false).Rows) { String InstanceName = dr["Name"].ToString(); if (InstanceName.Equals(xiSession["ComputerName"] + @"\" + xiSession["sqlINSTANCENAME"],StringComparison.InvariantCultureIgnoreCase)) { flag = true; } Record lRecord = xiSession.Database.CreateRecord(4); xiSession.Log("Setting record details"); lRecord.SetString(1,"DBSRVR"); lRecord.SetInteger(2,Index); lRecord.SetString(3,InstanceName); lRecord.SetString(4,InstanceName); xiSession.Log("Adding record"); lView.Modify(ViewModifyMode.InsertTemporary,lRecord); ++Index; } } catch (Exception ex) { logException(xiSession,ex); } if (flag) { xiSession["DBSRVR"] = xiSession["ComputerName"].ToString() + @"\" + xiSession["sqlINSTANCENAME"].ToString(); } lView.Close(); xiSession.Log("Closing view"); lView.Close(); return ActionResult.Success; }
原文地址:https://www.jb51.cc/mssql/75470.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。