{"id":163,"date":"2008-11-30T02:21:30","date_gmt":"2008-11-29T18:21:30","guid":{"rendered":""},"modified":"2014-02-27T22:57:28","modified_gmt":"2014-02-27T14:57:28","slug":"asp%e7%bc%93%e5%ad%98%e6%8a%80%e6%9c%af","status":"publish","type":"post","link":"http:\/\/www.xiaoyebailong.com\/index.php\/2008\/11\/30\/163.htm","title":{"rendered":"ASP\u7f13\u5b58\u6280\u672f"},"content":{"rendered":"<p>\u4f7f\u7528ASP\u4e2d\u7684\u7f13\u5b58\u6280\u672f\u53ef\u4ee5\u5f88\u5927\u7a0b\u5ea6\u4e0a\u63d0\u9ad8\u4f60\u7684\u7f51\u7ad9\u6027\u80fd\uff0c\u5176\u5b9e\u8fd9\u4e9b\u5b9e\u73b0\u65b9\u6cd5\u662f\u975e\u5e38\u7684\u7b80\u5355\uff0c\u5b83\u5c06\u8bf4\u660e\u5982\u4f55\u5728\u670d\u52a1\u5668\u4e0a\u7684\u7f13\u5b58\u662f\u5982\u4f55\u5de5\u4f5c\u4ee5\u53ca\u4f60\u5982\u4f55\u4f7f\u7528\u4e00\u79cd\u88ab\u79f0\u4e3a\u65ad\u5f00\u8fde\u63a5\u7684ADO\u8fde\u63a5\u6280\u672f\u3002 <br \/>\n\u3000\u3000\u5728\u4ecb\u7ecd\u8fd9\u4e9b\u6280\u672f\u4e4b\u524d\u5148\u8bf4\u660e\u4e00\u4e0b\u5230\u5e95\u4ec0\u4e48\u662fASP\u7684\u7f13\u5b58\u6280\u672f\u3002 <br \/>\n\u3000\u3000\u6240\u8c13\u7f13\u5b58\u5176\u5b9e\u5c31\u662f\u5728\u5185\u5b58\u4e2d\u5f00\u8f9f\u4e00\u4e2a\u7528\u6765\u4fdd\u5b58\u6570\u636e\u7684\u7a7a\u95f4\uff0c\u4f7f\u7528\u7f13\u5b58\u4f60\u5c31\u4e0d\u7528\u9891\u7e41\u7684\u8bbf\u95ee\u4f60\u4fdd\u5b58\u5728\u786c\u76d8\u4e0a\u7684\u6570\u636e\u4e86\uff0c\u7075\u6d3b\u7684\u4f7f\u7528\u7f13\u5b58\u4f60\u5c31\u514d\u53bb\u4e86\u5fc3\u75bc\u7684\u770b\u7740\u53ef\u601c\u7684\u786c\u76d8\u9971\u53d7\u8bfb\u6570\u636e\u65f6\u7684\u6298\u78e8\u4e86\u3002\u5f53\u4f60\u4e00\u65e6\u6267\u884c\u4e86\u4e00\u4e2a\u67e5\u8be2\u52a8\u4f5c\uff0c\u5e76\u4e14\u5c06\u67e5\u8be2\u7ed3\u679c\u653e\u5165\u7f13\u5b58\u4e2d\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u5f88\u8fc5\u901f\u7684\u91cd\u590d\u8bbf\u95ee\u8fd9\u4e9b\u6570\u636e\u4e86\u3002\u800c\u5982\u679c\u4f60\u4e0d\u628a\u6570\u636e\u653e\u5165\u7f13\u5b58\u7684\u8bdd\uff0c\u5f53\u4f60\u518d\u6b21\u6267\u884c\u8fd9\u4e2a\u67e5\u8be2\u65f6\uff0c\u670d\u52a1\u5668\u4f1a\u5c06\u8fdb\u7a0b\u8017\u8d39\u5728\u4ece\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u5e76\u6392\u5e8f\u4e0a\u4e86\u3002 <br \/>\n\u3000\u3000\u5f53\u6570\u636e\u4fdd\u5b58\u5728\u7f13\u5b58\u4e2d\u65f6\uff0c\u518d\u6b21\u67e5\u8be2\u65f6\u8017\u8d39\u7684\u65f6\u95f4\u4e3b\u8981\u662f\u5728\u663e\u793a\u6570\u636e\u7684\u65f6\u95f4\u4e0a\u4e86\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u4e0d\u5e94\u8be5\u628a\u7ecf\u5e38\u9700\u8981\u6539\u53d8\u7684\u6570\u636e\u653e\u5230\u670d\u52a1\u7aef\u7684\u7f13\u5b58\u4e2d\uff0c\u6211\u4eec\u5e94\u8be5\u628a\u6539\u53d8\u5c11\uff0c\u4f46\u662f\u53c8\u9700\u8981\u7ecf\u5e38\u8bbf\u95ee\u7684\u6570\u636e\u653e\u5230\u7f13\u5b58\u4e2d\u3002 <\/p>\n<p>\u3000\u3000\u73b0\u5728\u6211\u4eec\u5148\u8ba8\u8bbaASP\u5728\u670d\u52a1\u7aef\u4f7f\u7528\u7f13\u5b58\u7684\u6280\u672f\uff0c\u8fc7\u4f1a\u518d\u8ba8\u8bbaASP\u5982\u4f55\u5728\u5ba2\u6237\u7aef\u4f7f\u7528 <br \/>\n\u7f13\u5b58\u7684\u6280\u672f\u3002 <br \/>\n\u3000\u3000\u5f53\u4f60\u6709\u5927\u91cf\u7684\u6570\u636e\uff08\u9759\u6001\u7684\uff0c\u5c31\u662f\u8bf4\u53d8\u52a8\u6bd4\u8f83\u5c11\u7684\uff09\u9700\u8981\u663e\u793a\u7ed9\u5ba2\u6237\u7aef\u65f6\uff0c\u4f60\u5c31\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u670d\u52a1\u7aef\u7684\u7f13\u5b58\u6280\u672f\u4e86\u3002\u8fd9\u79cd\u6280\u672f\u5c24\u5176\u9002\u7528\u4e8e\u90a3\u4e9b\u663e\u793a\u98ce\u683c\u4e00\u81f4\u6027\u6bd4\u8f83\u5f3a\u7684\u7f51\u7ad9\uff08\u5475\u5475\uff0c\u5bf9\u4e8e\u975e\u4e3b\u6d41\u7684\u7f51\u7ad9\u53ef\u4e0d\u597d\u7528\u7684\u8bf4\u3002\uff09 <br \/>\n\u3000\u3000\u5176\u5b9e\u5b9e\u73b0\u65b9\u6cd5\u7279\u522b\u7684\u7b80\u5355\uff0c\u5927\u5bb6\u53ea\u8981\u770b\u770b\u4e0b\u9762\u8fd9\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u5c31\u660e\u767d\u4e86\u3002 <br \/>\n\u3000\u3000\u8fd9\u662f\u4e00\u4e2a\u7528\u6765\u663e\u793a\u4e66\u7c4d\u5206\u7c7b\u7684\u4f8b\u5b50\u7a0b\u5e8f <br \/>\nDisplayBooks.ASP\u6587\u4ef6\uff1a <\/p>\n<p>&lt; %@ LANGUAGE=JavaScript % &gt; <br \/>\n&lt; html &gt; <br \/>\n&lt; body &gt; <br \/>\n&lt; form method=post &gt; <br \/>\n\u4e66\u7c4d\u5206\u7c7b\uff1b &lt; %= getBooksListBox() % &gt; <br \/>\n&lt; p&gt; <br \/>\n&lt; input type=submit &gt; <\/p>\n<p>&lt; % <br \/>\nfunction getBooksListBox() <br \/>\n{ <br \/>\nBooksListBox = Application(&quot;BooksListBox&quot;) <br \/>\nif (BooksListBox != null) return BooksListBox; <br \/>\ncrlf = String.fromCharCode(13, 10) <br \/>\nBooksListBox = &quot;&lt; select name=Books&gt;&quot; + crlf; <br \/>\nSQL = &quot;SELECT * FROM Books ORDER BY Name&quot;; <br \/>\ncnnBooks = Server.CreateObject(&quot;ADODB.Connection&quot;); <br \/>\ncnnBooks.Open(&quot;Books&quot;, &quot;Admin&quot;,&quot;&quot;); <br \/>\nrstBooks = cnnBooks.Execute(SQL); <br \/>\nfldBookName = rstBooks(&quot;BookName&quot;); <br \/>\nwhile (!rstBooks.EOF){ <br \/>\nBooksListBox = BooksListBox + &quot; &lt; option&gt;&quot; + <br \/>\nfldBookName + &quot;&quot; + crlf; <br \/>\nrstBooks.MoveNext(); <br \/>\n} <br \/>\nBooksListBox = BooksListBox + &quot;&quot; <br \/>\nApplication(&quot;BooksListBox&quot;) = BooksListBox <br \/>\nreturn BooksListBox; <br \/>\n} <br \/>\n% &gt; <br \/>\n\u3000\u3000\u5f88\u7b80\u5355\u628a\uff0c\u5176\u5b9e\u5c31\u662f\u7528\u4e86\u5f88\u7b80\u5355\u7684Application\u6280\u672f\uff0c\u800c\u4e14\u5c31\u4e00\u53e5\u8bdd\u7684\u4e0d\u540c\uff1a <br \/>\n\u3000\u3000Application(&quot;BooksListBox&quot;) = BooksListBox <br \/>\n\u3000\u3000\u4f60\u53ef\u4ee5\u9a8c\u8bc1\u4e00\u4e0b\u4f60\u5c31\u4f1a\u53d1\u73b0\u670d\u52a1\u5668\u4e0a\u7684\u8bf7\u6c42\u6570\u91cf\u4f1a\u964d\u4f4e\u4e0d\u5c11\u7684\u3002\u8fd9\u79cd\u60c5\u51b5\u5c24\u5176\u9002\u5408\u4e0e\u90a3\u4e9b\u66f4\u65b0\u4e0d\u662f\u5f88\u9891\u7e41\u7684\u7f51\u7ad9\u5185\u5bb9\uff0c\u4f8b\u5982\u4f60\u4e00\u5929\uff08\u6216\u5219\u5f88\u957f\u65f6\u95f4\uff09\u53ea\u66f4\u65b0\u4e00\u6b21\u3002 <\/p>\n<p>\u3000\u3000\u4e0b\u9762\u518d\u8ba8\u8bba\u4e00\u79cd\u5ba2\u6237\u7aef\u7684\u7f13\u5b58\u6280\u672f\u8fd9\u79cd\u6280\u672f\u4e5f\u53eb\u65ad\u5f00\u8fde\u63a5\u7684ADO\u8fde\u63a5\u6280\u672f\uff08\u7ffb\u8bd1\u6c34\u5e73\u592a\u6b21\uff0c\u542c\u4e0a\u53bb\u600e\u4e48\u8fd9\u4e48\u522b\u626d\uff09\u3002\u8fd9\u79cd\u6280\u672f\u4e3b\u8981\u4f7f\u7528\u5728\u7528\u6765\u4fdd\u5b58\u7528\u6237\u4e2a\u4eba\u4fe1\u606f\uff0c\u4f8b\u5982\u7528\u6237\u7684\u5bc6\u7801\uff0c\u4ee3\u53f7\u7b49\u7b49\u4e0a\u9762\u3002\u5b83\u4e3b\u8981\u4f7f\u7528\u4e86ADO\u7684\u4e00\u4e9b\u5c5e\u6027\u3002\u540c\u65f6\u4e5f\u56de\u7b54\u4e86\u4e00\u4e9b\u7f51\u53cb\u66fe\u7ecf\u63d0\u5230\u8fc7\u7684\u80fd\u5426\u5728Applocation\u4e2d\u4f7f\u7528ADO\u5bf9\u8c61\u7684\u95ee\u9898\u3002\u89e3\u91ca\u4e0d\u6e05\u695a\uff0c\u4e0b\u9762\u8ba9\u4ee3\u7801\u6765\u53d1\u8a00\uff1a <br \/>\n\u6587\u4ef6GLOBAL.ASA\uff1a <br \/>\n&lt; !&#8211;METADATA TYPE=&quot;TypeLib&quot; FILE=&quot;C:\\Program Files\\Common Files\\system\\ado\\msado15.dll&quot;&#8211; &gt; <br \/>\n&lt; SCRIPT LANGUAGE=VBScript RUNAT=&quot;Server&quot; &gt; <br \/>\nSub Application_OnStart <br \/>\nSQL = &quot;SELECT UserName, Password FROM UserInfo&quot; <br \/>\ncnnUsers = &quot;DSN=User&quot; <br \/>\nSet rsUsers = Server.CreateObject(&quot;ADODB.Recordset&quot;) <br \/>\n&#8216;\u6ce8\u610f\u4e0b\u9762\u8fd9\u4e24\u53e5\u8bdd\uff0c\u5c31\u662f\u7528\u6765\u5b9e\u73b0\u90a3\u4e2a\u53eb\u53ef\u7528\u7684\u65ad\u5f00\u8fde\u63a5\u7684ADO\u6280\u672f <br \/>\nrsCustomers.CursorLocation = adUseClient <br \/>\nrsCustomers.Open SQL, cnnAdvWorks, adOpenStatic, AdLockReadOnly <br \/>\n&#8216; \u65ad\u5f00RecordSet\u7684\u548c\u6570\u636e\u5e93\u7684\u8fde\u63a5 <br \/>\nrsCustomers.ActiveConnection = Nothing <br \/>\nSet Application(&quot;rsCustomers&quot;) = rsCustomers <br \/>\nEnd Sub <\/p>\n<p>\n\u6587\u4ef6Users.ASP <br \/>\n&lt; % <br \/>\n&#8216;Clone\u65b9\u6cd5\u4f7f\u5f97\u6bcf\u4e2a\u7528\u6237\u62e5\u6709\u81ea\u5df1\u7684\u4e00\u4e2aRecordSet\u96c6\u5408 <br \/>\nSet yourUsers = Application(&quot;rsUsers&quot;).Clone <br \/>\nSet UserName = yourUsers(&quot;UserName&quot;) <br \/>\nSet Password = yourUsers(&quot;Password&quot;) <br \/>\nDo Until yourUsers.EOF <br \/>\n% &gt; <br \/>\n\u7528\u6237\u59d3\u540d\uff1a&lt; %= UserName % &gt; \u7528\u6237\u5bc6\u7801\uff1a&lt; %= Password % &gt; <br \/>\n&lt; % <br \/>\nyourUsers.MoveNext <br \/>\nLoop <br \/>\n% &gt;\u3000\u3000<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528ASP\u4e2d\u7684\u7f13\u5b58\u6280\u672f\u53ef\u4ee5\u5f88\u5927\u7a0b\u5ea6\u4e0a\u63d0\u9ad8\u4f60\u7684\u7f51\u7ad9\u6027\u80fd\uff0c\u5176\u5b9e\u8fd9\u4e9b\u5b9e\u73b0\u65b9\u6cd5\u662f\u975e\u5e38\u7684\u7b80\u5355\uff0c\u5b83\u5c06\u8bf4\u660e\u5982\u4f55\u5728\u670d\u52a1\u5668\u4e0a\u7684\u7f13\u5b58\u662f\u5982\u4f55\u5de5\u4f5c\u4ee5\u53ca\u4f60\u5982\u4f55\u4f7f\u7528\u4e00\u79cd\u88ab\u79f0\u4e3a\u65ad\u5f00\u8fde\u63a5\u7684ADO\u8fde\u63a5\u6280\u672f\u3002 \u3000\u3000\u5728\u4ecb\u7ecd\u8fd9\u4e9b\u6280\u672f\u4e4b\u524d\u5148\u8bf4\u660e\u4e00\u4e0b\u5230\u5e95\u4ec0\u4e48\u662fASP\u7684\u7f13\u5b58\u6280\u672f\u3002 \u3000\u3000&#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-163","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/163","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=163"}],"version-history":[{"count":1,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":66020,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/163\/revisions\/66020"}],"wp:attachment":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/tags?post=163"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/topic?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}