How to fix: DOMParser.TransformNode not supported in IE9

 

clip_image002

 

This issue can be fixed in IE9 by using the following javascript function:

 

/*
Transforms a XML document to a HTML string by using a XSLT document
1. Use type XSLTProcessor, if browser (FF, Safari, Chrome etc) supports it
2. Use function [transformNode] on the XmlDocument, if browser (IE6, IE7, IE8) supports it
3. Use function transform on the XsltProcessor used for IE9 (which doesn't support [transformNode] any more) 
4. Throws an error, when both types are not supported
*/
function TransformToHtmlText(xmlDoc, xsltDoc) {
// 1.
if (typeof (XSLTProcessor) != "undefined") {
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltDoc);
var xmlFragment = xsltProcessor.transformToFragment(xmlDoc, document);
return GetXmlStringFromXmlDoc(xmlFragment);
}
// 2.
if (typeof (xmlDoc.transformNode) != "undefined") {
return xmlDoc.transformNode(xsltDoc);
}
else {
try {
// 3
if (window.ActiveXObject) {
var xslt = new ActiveXObject("Msxml2.XSLTemplate");
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
xslDoc.loadXML(xsltDoc.xml);
xslt.stylesheet = xslDoc;
var xslProc = xslt.createProcessor();
xslProc.input = xmlDoc;
xslProc.transform();
return xslProc.output;
}
}
catch (e) {
// 4
alert("The type [XSLTProcessor] and the function [XmlDocument.transformNode] are not supported by this browser, can't transform XML document to HTML string!");
return null;
}
}
}

Drop all connections to a SQL Server database with T-SQL

If you want to drop all connections to a database by using T-SQL, connect Microsoft SQL Server Management Studio to the master database, open a new query editor window and execute the following T-SQL code:

 

/*
Drop all connections to a database
*/
-- Take database offline
alter database [MyDatabase]
set offline with rollback immediate
-- Take database online
alter database [MyDatabase]
set online