{"id":666,"date":"2011-01-28T09:39:20","date_gmt":"2011-01-28T01:39:20","guid":{"rendered":""},"modified":"2014-03-11T22:36:24","modified_gmt":"2014-03-11T14:36:24","slug":"asp%e4%b8%ad%e5%a6%82%e4%bd%95%e8%b0%83%e7%94%a8sql%e8%87%aa%e5%ae%9a%e4%b9%89%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"http:\/\/www.xiaoyebailong.com\/index.php\/2011\/01\/28\/666.htm","title":{"rendered":"ASP\u4e2d\u5982\u4f55\u8c03\u7528SQL\u81ea\u5b9a\u4e49\u51fd\u6570"},"content":{"rendered":"<p><strong>\u518dASP\u7a0b\u5e8f\u4e2d\u5982\u4f55\u8c03\u7528SQL\u81ea\u5b9a\u4e49\u51fd\u6570\u5462\uff1f<\/strong><\/p>\n<p>\n&nbsp;<\/p>\n<p><strong>\u8fd9\u662f\u6211\u7684\u8c03\u7528\u65b9\u6cd5\uff0c\u9ebb\u70e6\u5404\u4f4d\u7ed9\u6307\u70b9\u4e00\u4e0b<\/strong><\/p>\n<p>\n&nbsp;<\/p>\n<p><strong>&lt;%<br \/>\nDim connectionText,connections,cmdTemp,rst<\/strong><\/p>\n<p>\n&nbsp;<\/p>\n<p><strong>connectionText=&quot;\u4f60\u597d&lt;script&quot; <br \/>\nSet conn = Server.CreateObject(&quot;ADODB.Connection&quot;) <br \/>\nconnections = &quot;driver={SQL Server};server=.;uid=sa;pwd=;database=luntandb&quot;<br \/>\nconn.open connections <\/strong><\/p>\n<p>\n&nbsp;<\/p>\n<p><strong>Set cmdTemp=Server.CreateObject(&quot;ADODB.Command&quot;)<br \/>\nSet rst=Server.CreateObject(&quot;ADODB.Recordset&quot;) <br \/>\ncmdTemp.commandText = &quot;dbo.HtmlEncode&quot; &#8216;\u81ea\u5b9a\u4e49\u51fd\u6570\u540d\u79f0<br \/>\ncmdTemp.CommandType = 4 <br \/>\nSet cmdTemp.ActiveConnection = conn <br \/>\ncmdTemp(&quot;@contentText&quot;) = connectionText <br \/>\ncmdTemp.execute() <br \/>\nrv =cmdTemp(&quot;@return_value&quot;) <br \/>\nresponse.Write(rv)<br \/>\n%&gt;<\/strong><\/p>\n<p>\n&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\n&nbsp;<\/p>\n<p><strong>\u8fd9\u662fSQL\u81ea\u5b9a\u4e49\u51fd\u6570&#8211; =============================================<br \/>\n&#8212; Author: &lt;Author,,Name&gt;<br \/>\n&#8212; Create date: &lt;Create Date, ,&gt;<br \/>\n&#8212; Description: &lt;Description, ,&gt;<br \/>\n&#8212; =============================================<br \/>\nALTER FUNCTION [dbo].[HtmlEncode]<br \/>\n(<br \/>\n@contentText varchar(5000)<br \/>\n)<br \/>\nRETURNS varchar(5000)<br \/>\nAS<br \/>\nBEGIN<\/strong><\/p>\n<p>\n&nbsp;<\/p>\n<p><strong>SET @contentText = REPLACE(@contentText,'&lt;script&#8217;,&#8217;&amp;lt;script&#8217;);<br \/>\nSET @contentText = REPLACE(@contentText,'&lt;link&#8217;,&#8217;&amp;lt;link&#8217;);<br \/>\nSET @contentText = REPLACE(@contentText,'&lt;ifream&#8217;,&#8217;&amp;lt;ifream&#8217;);<br \/>\nSET @contentText = REPLACE(@contentText,'&lt;style&#8217;,&#8217;&amp;lt;style&#8217;);<br \/>\nSET @contentText = REPLACE(@contentText,&#8217;url(&#8216;,&#8217;url\uff08&#8217;);<br \/>\nRETURN @contentText<br \/>\nEND<\/strong><\/p>\n<p>\n&nbsp;<\/p>\n<div class=\"question_author\">&nbsp;<\/div>\n<p>\n<b>\u95ee\u9898\u8865\u5145\uff1a<\/b>\u521a\u624d\u4fee\u6539\u4e86\u4e00\u4e0b\uff0c\u7528SQL\u8bed\u53e5\u8c03\u7528\uff0c\u73b0\u5728\u6539\u6210\u8fd9\u6837<br \/>\nDim str,ContentText <br \/>\nSet conn = Server.CreateObject(&quot;ADODB.Connection&quot;) <br \/>\nconnections = &quot;driver={SQL Server};server=.;uid=sa;pwd=;database=luntandb&quot;<br \/>\nconn.open connections<br \/>\nContentText=&quot;\u6d4b\u8bd5\u6d4b\u8bd5\u6d4b\u8bd5&lt;script&gt;alert(&#8216;\u6d4b\u8bd5&#8217;)&lt;\/script&gt;&quot;<br \/>\nSet rst=Server.CreateObject(&quot;ADODB.Recordset&quot;) <br \/>\nstr=&quot;select dbo.HtmlEncode(&#8216;&quot;&amp;ContentText&amp;&quot;&#8217;)&quot;<br \/>\nrst.open str,conn,1,1<br \/>\nresponse.Write(rst(0)) <br \/>\n%&gt;<br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u518dASP\u7a0b\u5e8f\u4e2d\u5982\u4f55\u8c03\u7528SQL\u81ea\u5b9a\u4e49\u51fd\u6570\u5462\uff1f &nbsp; \u8fd9\u662f\u6211\u7684\u8c03\u7528\u65b9\u6cd5\uff0c\u9ebb\u70e6\u5404\u4f4d\u7ed9\u6307\u70b9\u4e00\u4e0b &nbsp; &lt;% Dim connectionText,connections,cmdTemp,rst &nbsp; connectio&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-666","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/comments?post=666"}],"version-history":[{"count":1,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/666\/revisions"}],"predecessor-version":[{"id":66538,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/666\/revisions\/66538"}],"wp:attachment":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/media?parent=666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/categories?post=666"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/tags?post=666"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/topic?post=666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}