Article View: pl.comp.xml
Article #9566[BTW] SQL -> XML
From: TOUDIdel
Date: Mon, 19 Nov 2007 20:46
Date: Mon, 19 Nov 2007 20:46
34 lines
2050 bytes
2050 bytes
Ktoś ostatnio pytał mnie o to ale zgubiłem maila więc tu odpowiadam.
Problem dotyczył: jak od zapytania SELECT FOR XML w Sql Serverze przejść do
xml'a w obiekcie msxml2.domdocument?
var txml=new ActiveXObject('msxml2.domdocument');txml.async=false;
txml.appendChild(txml.createProcessingInstruction('xml','version="1.0"'));
var sConn =
"Provider=SQLOLEDB;Server=mssql\\sqlexpress;Database=xmlguru;Trusted_Connection=yes";
var adoConn = new ActiveXObject("ADODB.Connection");
adoConn.ConnectionString = sConn;
adoConn.CursorLocation = 3;
adoConn.Open();
var adoCmd = new ActiveXObject("ADODB.Command");
adoCmd.ActiveConnection = adoConn;
var sQuery = "<R
xmlns:sql='urn:schemas-microsoft-com:xml-sql'><sql:query>SELECT * FROM Users
WHERE url='xmlguru.net' FOR XML AUTO</sql:query></R>";
var adoStreamQuery = new ActiveXObject("ADODB.Stream");
adoStreamQuery.Open();
adoStreamQuery.WriteText(sQuery,0);
adoStreamQuery.Position = 0;
adoCmd.CommandStream = adoStreamQuery;
adoCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}";
adoCmd.Properties("Output Stream") = txml;
adoCmd.Execute(0,0,1024);
WScript.Echo(txml.xml);
--
td
Technical Details
Message-ID:
<fhsspu$2v2$1@atlantis.news.tpi.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail From: "TOUDIdel" <toudidel@oDWA.pl> Newsgroups: pl.comp.xml Subject: [BTW] SQL -> XML Date: Mon, 19 Nov 2007 21:46:54 +0100 Organization: tp.internet - http://www.tpi.pl/ Lines: 36 Message-ID: <fhsspu$2v2$1@atlantis.news.tpi.pl> NNTP-Posting-Host: aaig104.neoplus.adsl.tpnet.pl X-Trace: atlantis.news.tpi.pl 1195505278 3042 83.4.214.104 (19 Nov 2007 20:47:58 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: Mon, 19 Nov 2007 20:47:58 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Original MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit