{"id":112,"date":"2010-05-20T20:05:09","date_gmt":"2010-05-20T20:05:09","guid":{"rendered":"7f6ffaa6bb0b408017b62254211691b5"},"modified":"2010-05-20T20:05:09","modified_gmt":"2010-05-20T20:05:09","slug":"","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/112","title":{"rendered":"\u6f14\u7ec3\u5982\u4f55\u7f13\u5b58\u4f9d\u8d56\u4e8e SQL Server \u6570\u636e\u5e93\u4e2d\u6570\u636e\u7684 ASP.NET \u9875"},"content":{"rendered":"<p>\u6b64\u6f14\u7ec3\u6f14\u793a\u5982\u4f55\u7f13\u5b58\u4f9d\u8d56\u4e8e SQL Server \u6570\u636e\u5e93\u4e2d\u6570\u636e\u7684 ASP.NET \u9875\u3002<\/p>\n<p>ASP.NET \u8f93\u51fa\u7f13\u5b58\u7684\u4e00\u9879\u9ad8\u7ea7\u529f\u80fd\u662f SQL \u7f13\u5b58\u4f9d\u8d56\u9879\u3002SQL \u7f13\u5b58\u4f9d\u8d56\u9879\u4f7f\u60a8\u53ef\u4ee5\u7f13\u5b58\u4f9d\u8d56\u4e8e SQL Server \u8868\u4e2d\u6570\u636e\u7684\u9875\u3002\u60a8\u53ef\u4ee5\u914d\u7f6e SQL Server \u548c ASP.NET \u4ee5\u7f13\u5b58\u9875\u8bf7\u6c42\uff0c\u964d\u4f4e\u670d\u52a1\u5668\u5de5\u4f5c\u8d1f\u8377\uff0c\u76f4\u5230\u9875\u6240\u4f9d\u8d56\u7684\u6570\u636e\u5df2\u5728 SQL Server \u4e2d\u66f4\u65b0\u4e3a\u6b62\u3002\u5bf9\u4e8e\u76f8\u5bf9\u4fdd\u6301\u9759\u6001\u7684\u4ea7\u54c1\u76ee\u5f55\u6216\u5ba2\u6237\u6ce8\u518c\u4fe1\u606f\u7b49\u6570\u636e\u800c\u8a00\uff0cSQL \u7f13\u5b58\u4f9d\u8d56\u9879\u5f88\u6709\u7528\u3002 <\/p>\n<p>\u672c\u6f14\u7ec3\u4e2d\u9610\u91ca\u7684\u4efb\u52a1\u5305\u62ec\uff1a <\/p>\n<p>\u521b\u5efa\u5e76\u914d\u7f6e\u9875\uff0c\u4ee5\u663e\u793a Northwind \u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u3002<\/p>\n<p>\u4e3a SQL \u7f13\u5b58\u901a\u77e5\u542f\u7528\u6570\u636e\u5e93\u3002<\/p>\n<p>\u5728\u9875\u4ee5\u53ca Web.config \u6587\u4ef6\u4e2d\u6307\u5b9a SQL \u7f13\u5b58\u4f9d\u8d56\u9879\u3002<\/p>\n<p>\u5bf9 Northwind \u6570\u636e\u5e93\u8fdb\u884c\u66f4\u6539\u5e76\u67e5\u770b\u7f13\u5b58\u884c\u4e3a\u3002<\/p>\n<p>\u5148\u51b3\u6761\u4ef6 <br \/>\u82e5\u8981\u5b8c\u6210\u672c\u6f14\u7ec3\uff0c\u60a8\u9700\u8981\uff1a<\/p>\n<p>\u5bf9\u5177\u6709 Northwind \u6570\u636e\u5e93\u7684 SQL Server 2000 \u6216 SQL Server 2005 \u7684\u8bbf\u95ee\u3002<\/p>\n<p>SQL Server Northwind \u6570\u636e\u5e93\u7684\u8bbf\u95ee\u6743\u9650\u3002\u6709\u5173\u4e0b\u8f7d\u548c\u5b89\u88c5 SQL Server \u793a\u4f8b\u6570\u636e\u5e93 Northwind \u7684\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1\u4f4d\u4e8e Microsoft SQL Server \u7f51\u7ad9\u4e0a\u7684&ldquo;Installing Sample Databases&rdquo;\uff08\u5b89\u88c5\u793a\u4f8b\u6570\u636e\u5e93\uff09\u3002<\/p>\n<p>\u6ce8\u610f <br \/>\u5982\u679c\u9700\u8981\u6709\u5173\u5982\u4f55\u767b\u5f55\u5230\u8fd0\u884c SQL Server \u7684\u8ba1\u7b97\u673a\u7684\u4fe1\u606f\uff0c\u8bf7\u4e0e\u670d\u52a1\u5668\u7ba1\u7406\u5458\u8054\u7cfb\u3002<\/p>\n<p>Microsoft \u6570\u636e\u8bbf\u95ee\u7ec4\u4ef6 (MDAC) 2.7 \u7248\u6216\u66f4\u9ad8\u7248\u672c\u3002<\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f Windows XP \u6216 Windows Server 2003\uff0c\u90a3\u4e48\u60a8\u5df2\u7ecf\u6709\u4e86 MDAC 2.7\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f7f\u7528 Windows 2000\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5347\u7ea7\u60a8\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u7684 MDAC\u3002\u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1 MSDN \u6587\u7ae0&ldquo;MDAC Installation&rdquo;\uff08MDAC \u5b89\u88c5\uff09\u3002<\/p>\n<p>.NET Framework 2.0 \u7248\u3002<\/p>\n<p>\u521b\u5efa\u7f51\u7ad9 <br \/>\u5982\u679c\u60a8\u5df2\u5728 Visual Web Developer \u4e2d\u521b\u5efa\u4e86\u7f51\u7ad9\uff08\u8bf7\u53c2\u89c1 \u6f14\u7ec3\uff1a\u5728 Visual Web Developer \u4e2d\u521b\u5efa\u57fa\u672c\u7f51\u9875\uff09\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u8be5\u7f51\u7ad9\u5e76\u8f6c\u81f3\u672c\u6f14\u7ec3\u7684\u540e\u9762\u90e8\u5206&ldquo;\u4e3a SQL Server \u542f\u7528\u7f13\u5b58\u901a\u77e5&rdquo;\u3002\u5426\u5219\uff0c\u6309\u7167\u4e0b\u9762\u7684\u6b65\u9aa4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7f51\u7ad9\u548c\u7f51\u9875\u3002<\/p>\n<p>\u521b\u5efa\u6587\u4ef6\u7cfb\u7edf\u7f51\u7ad9<br \/>\u6253\u5f00 Visual Web Developer\u3002<\/p>\n<p>\u5728&ldquo;\u6587\u4ef6&rdquo;\u83dc\u5355\u4e0a\u5355\u51fb&ldquo;\u65b0\u5efa\u7f51\u7ad9&rdquo;\u3002\uff08\u5728 Visual Web Developer \u901f\u6210\u7248\u4e2d\uff0c\u5728&ldquo;\u6587\u4ef6&rdquo;\u83dc\u5355\u4e0a\u5355\u51fb&ldquo;\u65b0\u5efa&rdquo;\uff0c\u7136\u540e\u5355\u51fb&ldquo;\u7f51\u7ad9&rdquo;\u3002\uff09<\/p>\n<p>\u51fa\u73b0&ldquo;\u65b0\u5efa\u7f51\u7ad9&rdquo;\u5bf9\u8bdd\u6846\u3002<\/p>\n<p>\u5728&ldquo;Visual Studio \u5df2\u5b89\u88c5\u7684\u6a21\u677f&rdquo;\u4e4b\u4e0b\u5355\u51fb&ldquo;ASP.NET \u7f51\u7ad9&rdquo;\u3002<\/p>\n<p>\u5728&ldquo;\u4f4d\u7f6e&rdquo;\u6846\u4e2d\u8f93\u5165\u8981\u4fdd\u5b58\u7f51\u7ad9\u9875\u9762\u7684\u6587\u4ef6\u5939\u7684\u540d\u79f0\u3002 <\/p>\n<p>\u4f8b\u5982\uff0c\u952e\u5165\u6587\u4ef6\u5939\u540d C:\\WebSites\u3002<\/p>\n<p>\u5728&ldquo;\u8bed\u8a00&rdquo;\u5217\u8868\u4e2d\uff0c\u5355\u51fb\u60a8\u60f3\u4f7f\u7528\u7684\u7f16\u7a0b\u8bed\u8a00\u3002<\/p>\n<p>\u5355\u51fb&ldquo;\u786e\u5b9a&rdquo;\u3002<\/p>\n<p>Visual Web Developer \u521b\u5efa\u8be5\u6587\u4ef6\u5939\u548c\u4e00\u4e2a\u540d\u4e3a Default.aspx \u7684\u65b0\u9875\u3002<\/p>\n<p>\u4e3a SQL Server \u542f\u7528\u7f13\u5b58\u901a\u77e5 <br \/>\u5fc5\u987b\u914d\u7f6e SQL Server \u4ee5\u5c31\u4f9d\u8d56\u6570\u636e\u4e2d\u7684\u66f4\u6539\u5411 ASP.NET \u63d0\u4f9b\u5408\u9002\u7684\u901a\u77e5\u3002\u60a8\u9700\u8981\u5177\u6709\u7ba1\u7406\u7279\u6743\u624d\u80fd\u914d\u7f6e\u670d\u52a1\u5668\u3002<\/p>\n<p>\u4e3a SQL Server \u542f\u7528\u7f13\u5b58\u901a\u77e5<br \/>\u5728 Windows&ldquo;\u542f\u52a8&rdquo;\u83dc\u5355\u4e2d\uff0c\u6307\u5411&ldquo;\u6240\u6709\u7a0b\u5e8f&rdquo;\uff0c\u6307\u5411&ldquo;\u9644\u4ef6&rdquo;\uff0c\u7136\u540e\u5355\u51fb&ldquo;\u547d\u4ee4\u63d0\u793a\u7b26&rdquo;\u4ee5\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7a97\u53e3\u3002<\/p>\n<p>\u5728\u78c1\u76d8\u9a71\u52a8\u5668\u4e2d\u627e\u5230 Aspnet_regsql.exe \u53ef\u6267\u884c\u6587\u4ef6\u3002\u6b64\u6587\u4ef6\u968f .NET Framework 2.0 \u7248\u5b89\u88c5\u5728\u4e0b\u9762\u7684\u4f4d\u7f6e\uff1a<\/p>\n<p>\u590d\u5236\u4ee3\u7801<br \/>%windir%\\Microsoft.NET\\Framework\\FrameworkVersion<\/p>\n<p>\u786e\u4fdd %windir% \u8868\u793a Windows \u76ee\u5f55\u5e76\u4e14 .NET Framework \u7248\u672c\u4e3a 2.0 \u6216\u66f4\u9ad8\u7248\u672c\u3002\u8be5\u8def\u5f84\u53ef\u80fd\u770b\u8d77\u6765\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u8fd9\u6837\uff1a<\/p>\n<p>\u590d\u5236\u4ee3\u7801<br \/>C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.40217<\/p>\n<p>\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u4e3a Northwind \u6570\u636e\u5e93\u4e2d\u7684 Employees \u8868\u542f\u7528\u7f13\u5b58\u901a\u77e5\uff1a<\/p>\n<p>\u590d\u5236\u4ee3\u7801<br \/>aspnet_regsql.exe -S &lt;Server&gt; -U &lt;Username&gt; -P &lt;Password&gt; -ed -d Northwind -et -t Employees<br \/>\u6ce8\u610f <br \/>\u60a8\u9700\u8981\u5177\u6709\u7ba1\u7406\u7279\u6743\uff0c\u6216\u7ba1\u7406\u5e10\u6237\u548c\u5bc6\u7801\u3002\u5982\u679c\u6ca1\u6709\u6b64\u4fe1\u606f\uff0c\u8bf7\u4e0e\u6570\u636e\u5e93\u7ba1\u7406\u5458\u8054\u7cfb\u3002<\/p>\n<p>\u5c06\u51fa\u73b0\u4e00\u6761\u6d88\u606f\uff0c\u6307\u793a\u542f\u7528\u6570\u636e\u5e93\u7684\u6210\u529f\u4e0e\u5931\u8d25\u3002\u4e0b\u9762\u7684\u6d88\u606f\u6307\u793a\u6210\u529f\uff1a<\/p>\n<p>\u590d\u5236\u4ee3\u7801<br \/>Enabling the table for SQL cache dependency.<br \/>..<br \/>Finished.<\/p>\n<p>\u5411\u9879\u76ee\u4e2d\u6dfb\u52a0\u6570\u636e\u8fde\u63a5 <br \/>\u8981\u5728 Visual Web Developer \u4e2d\u4f7f\u7528 SQL Server \u6570\u636e\u5e93\uff0c\u60a8\u9700\u8981\u5411 Northwind \u6570\u636e\u5e93\u6dfb\u52a0\u8fde\u63a5\u3002<\/p>\n<p>\u5411\u9879\u76ee\u6dfb\u52a0\u6570\u636e\u6e90<br \/>\u5728&ldquo;\u670d\u52a1\u5668\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff08Visual Web Developer \u901f\u6210\u7248\u4e2d\u4e3a&ldquo;\u6570\u636e\u5e93\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff09\u4e2d\uff0c\u53f3\u51fb&ldquo;\u6570\u636e\u8fde\u63a5&rdquo;\uff0c\u7136\u540e\u5355\u51fb&ldquo;\u6dfb\u52a0\u8fde\u63a5&rdquo;\u3002 <\/p>\n<p>\u6ce8\u610f <br \/>&ldquo;\u670d\u52a1\u5668\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff08Visual Web Developer \u901f\u6210\u7248\u4e2d\u4e3a&ldquo;\u6570\u636e\u5e93\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff09\u901a\u5e38\u505c\u9760\u5728\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u540e\u9762\u3002<\/p>\n<p>\u5982\u679c&ldquo;\u670d\u52a1\u5668\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff08Visual Web Developer \u901f\u6210\u7248\u4e2d\u4e3a&ldquo;\u6570\u636e\u5e93\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff09\u4e0d\u53ef\u89c1\uff0c\u5219\u5728&ldquo;\u89c6\u56fe&rdquo;\u83dc\u5355\u4e2d\u5355\u51fb&ldquo;\u670d\u52a1\u5668\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff08Visual Web Developer \u901f\u6210\u7248\u4e2d\u4e3a&ldquo;\u6570\u636e\u5e93\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff09\u3002<\/p>\n<p>\u5982\u679c\u663e\u793a&ldquo;\u9009\u62e9\u6570\u636e\u6e90&rdquo;\u5bf9\u8bdd\u6846\uff0c\u5219\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<p>\u5728&ldquo;\u6570\u636e\u6e90&rdquo;\u5217\u8868\u4e2d\uff0c\u5355\u51fb&ldquo;Microsoft SQL Server&rdquo;\u3002<\/p>\n<p>\u5728&ldquo;\u6570\u636e\u63d0\u4f9b\u7a0b\u5e8f&rdquo;\u5217\u8868\u4e2d\uff0c\u5355\u51fb&ldquo;\u7528\u4e8e SQL Server \u7684 .NET Framework \u6570\u636e\u63d0\u4f9b\u7a0b\u5e8f&rdquo;\u3002<\/p>\n<p>\u5355\u51fb&ldquo;\u7ee7\u7eed&rdquo;\u3002<\/p>\n<p>\u5728&ldquo;\u6dfb\u52a0\u8fde\u63a5&rdquo;\u5bf9\u8bdd\u6846\u4e2d\uff0c\u4e3a\u6570\u636e\u5e93\u63d0\u4f9b\u8be6\u7ec6\u4fe1\u606f\uff08\u670d\u52a1\u5668\u540d\u79f0\u3001\u767b\u5f55\u51ed\u636e\u7b49\uff09\uff0c\u7136\u540e\u9009\u62e9 Northwind \u6570\u636e\u5e93\u3002<\/p>\n<p>\u5355\u51fb&ldquo;\u786e\u5b9a&rdquo;\u3002<\/p>\n<p>\u5411\u7f51\u9875\u6dfb\u52a0\u65f6\u95f4\u6233\u548c\u6570\u636e <br \/>\u73b0\u5728\u53ef\u4ee5\u521b\u5efa\u7f51\u9875\u6765\u6f14\u793a\u7f13\u5b58\u5904\u7406\u3002\u5728\u672c\u8282\u4e2d\uff0c\u60a8\u5c06\u6dfb\u52a0\u4e00\u4e2a\u65f6\u95f4\u6233\u6765\u8ddf\u8e2a\u9875\u521b\u5efa\u65f6\u95f4\uff0c\u5e76\u6dfb\u52a0\u4e00\u4e2a GridView \u63a7\u4ef6\u6765\u67e5\u770b Northwind \u6570\u636e\u5e93\u7684 Employees \u8868\u3002<\/p>\n<p>\u5411\u7f51\u9875\u6dfb\u52a0\u65f6\u95f4\u6233\u548c\u6570\u636e<br \/>\u5207\u6362\u5230\u6216\u6253\u5f00 Default.aspx \u9875\u3002<\/p>\n<p>\u5207\u6362\u5230&ldquo;\u8bbe\u8ba1&rdquo;\u89c6\u56fe\u3002<\/p>\n<p>\u4ece\u5de5\u5177\u7bb1\u7684&ldquo;\u6807\u51c6&rdquo;\u7ec4\u4e2d\uff0c\u5c06\u4e00\u4e2a Label \u63a7\u4ef6\u62d6\u5230\u9875\u4e0a\uff0c\u4fdd\u7559\u9ed8\u8ba4\u540d\u79f0 Label1\u3002<\/p>\n<p>\u5728&ldquo;\u670d\u52a1\u5668\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff08Visual Web Developer \u901f\u6210\u7248\u4e2d\u4e3a&ldquo;\u6570\u636e\u5e93\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff09\u4e2d\uff0c\u5c55\u5f00&ldquo;\u6570\u636e\u8fde\u63a5&rdquo;\u3002<\/p>\n<p>\u4e3a\u4ee5\u524d\u521b\u5efa\u7684\u6570\u636e\u8fde\u63a5\u5c55\u5f00\u8282\u70b9\u3002<\/p>\n<p>\u5c55\u5f00&ldquo;\u8868&rdquo;\u8282\u70b9\u3002<\/p>\n<p>\u5c06 Employees \u8868\u62d6\u5230\u9875\u4e0a\u3002<\/p>\n<p>Visual Web Designer \u521b\u5efa\u4e00\u4e2a GridView \u63a7\u4ef6\uff0c\u5b83\u914d\u7f6e\u4e3a\u4f7f\u7528\u60a8\u6240\u9009\u62e9\u7684\u8fde\u63a5\u548c\u8868\u3002<\/p>\n<p>\u5728&ldquo;GridView \u4efb\u52a1&rdquo;\u83dc\u5355\u4e0a\uff0c\u5355\u51fb&ldquo;\u914d\u7f6e\u6570\u636e\u6e90\u3002<\/p>\n<p>\u9ed8\u8ba4\u6570\u636e\u8fde\u63a5\u5b57\u7b26\u4e32\u540d\u79f0 NorthwindConnectionString1 \u51fa\u73b0\u5728&ldquo;\u914d\u7f6e\u6570\u636e\u6e90&rdquo;\u5411\u5bfc\u7684\u7b2c\u4e00\u4e2a\u6b65\u9aa4\u4e2d\u3002<\/p>\n<p>\u5355\u51fb&ldquo;\u4e0b\u4e00\u6b65&rdquo;\u3002<\/p>\n<p>\u5728&ldquo;\u914d\u7f6e Select \u8bed\u53e5&rdquo;\u7a97\u683c\u4e2d\uff0c\u9009\u62e9&ldquo;\u6307\u5b9a\u6765\u81ea\u8868\u6216\u89c6\u56fe\u7684\u5217&rdquo;\u3002<\/p>\n<p>\u5728&ldquo;\u540d\u79f0&rdquo;\u5217\u8868\u4e2d\uff0c\u5355\u51fb Employees\u3002<\/p>\n<p>\u5728&ldquo;\u5217&rdquo;\u5217\u8868\u4e2d\uff0c\u9009\u62e9 EmployeeID\u3001LastName \u548c FirstName \u5217\u3002<\/p>\n<p>\u5355\u51fb&ldquo;\u4e0b\u4e00\u6b65&rdquo;\u3002<\/p>\n<p>\u5355\u51fb&ldquo;\u5b8c\u6210&rdquo;\u3002<\/p>\n<p>Visual Web Designer \u914d\u7f6e GridView \u63a7\u4ef6\u4ee5\u663e\u793a\u60a8\u6240\u9009\u62e9\u7684\u6570\u636e\u3002<\/p>\n<p>\u6ce8\u610f <br \/>\u5982\u679c\u770b\u5230\u4e00\u6761\u6d88\u606f\u8be2\u95ee\u60a8\u662f\u5426\u8981\u5237\u65b0 GridView \u63a7\u4ef6\u7684\u5b57\u6bb5\u548c\u952e\uff0c\u5355\u51fb&ldquo;\u662f&rdquo;\u3002<\/p>\n<p>\u53cc\u51fb\u9875\u7684\u7a7a\u767d\u90e8\u5206\u3002<\/p>\n<p>\u8bbe\u8ba1\u5668\u751f\u6210 Page_Load \u65b9\u6cd5\u5e76\u5207\u6362\u89c6\u56fe\u3002<\/p>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u7a81\u51fa\u663e\u793a\u7684\u4ee3\u7801\uff0c\u4ee5\u663e\u793a\u6307\u793a\u9875\u521b\u5efa\u7684\u65f6\u95f4\u6233\uff1a<\/p>\n<p>Visual Basic \u590d\u5236\u4ee3\u7801<br \/>Protected Sub Page_Load(ByVal sender As Object, _<br \/>ByVal e As System.EventArgs) _<br \/>Handles Me.Load<br \/>Label1.Text = System.DateTime.Now<br \/>End Sub<\/p>\n<p>C# \u590d\u5236\u4ee3\u7801<br \/>protected void Page_Load(Object sender, System.EventArgs e)<br \/>{<br \/>Label1.Text = System.DateTime.Now.ToString();<br \/>}<\/p>\n<p>\u4fdd\u5b58\u8be5\u6587\u4ef6\u3002<\/p>\n<p>\u6d4b\u8bd5\u4e0d\u4f7f\u7528\u7f13\u5b58\u529f\u80fd\u7684\u9875 <br \/>\u73b0\u5728\u53ef\u4ee5\u8fd0\u884c\u9875\uff0c\u5e76\u89c2\u5bdf\u4e0d\u4f7f\u7528\u7f13\u5b58\u529f\u80fd\u7684\u884c\u4e3a\u3002\u6b64\u65f6\u5c06\u52a0\u8f7d\u9875\u5e76\u663e\u793a\u5f53\u524d\u670d\u52a1\u5668\u65f6\u95f4\uff0c\u7136\u540e\u5c06\u68c0\u7d22\u6570\u636e\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u9875\u4e2d\u3002<\/p>\n<p>\u6d4b\u8bd5\u4e0d\u4f7f\u7528\u7f13\u5b58\u529f\u80fd\u7684\u9875<br \/>\u6309 Ctrl+F5 \u8fd0\u884c\u8be5\u9875\u3002<\/p>\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u5237\u65b0\u9875<\/p>\n<p>\u6ce8\u610f\uff0c\u65f6\u95f4\u6233\u968f\u7740\u6bcf\u6b21\u9875\u5237\u65b0\u800c\u66f4\u6539\u3002\u6570\u636e\u5c06\u4fdd\u6301\u76f8\u540c\u3002<\/p>\n<p>\u4e3a\u7f13\u5b58\u529f\u80fd\u914d\u7f6e\u7f51\u9875 <br \/>\u5728\u672c\u90e8\u5206\u6f14\u7ec3\u4e2d\uff0c\u60a8\u5c06\u57fa\u4e8e Northwind \u6570\u636e\u5e93\u7684 Employees \u8868\u4e3a SQL \u7f13\u5b58\u4f9d\u8d56\u9879\u914d\u7f6e\u9875\u3002<\/p>\n<p>\u4e3a\u7f13\u5b58\u529f\u80fd\u914d\u7f6e\u7f51\u9875<br \/>\u5207\u6362\u5230&ldquo;\u6e90&rdquo;\u89c6\u56fe\u3002<\/p>\n<p>\u5728\u9875\u9876\u90e8\uff0c\u6dfb\u52a0\u4e0b\u9762\u7684\u6307\u4ee4\u4ee5\u6307\u793a\u4f9d\u8d56\u9879\uff1a<\/p>\n<p>\u590d\u5236\u4ee3\u7801<br \/>&lt;%@ OutputCache Duration=&quot;3600&quot; SqlDependency=&quot;Northwind:Employees&quot; VaryByParam=&quot;none&quot; %&gt;<\/p>\n<p>VaryByParam \u5c5e\u6027\u6307\u793a\u7f13\u5b58\u65f6 ASP.NET \u662f\u5426\u5e94\u8003\u8651\u9875\u53c2\u6570\uff08\u5982\u67e5\u8be2\u5b57\u7b26\u4e32\u6216\u53d1\u5e03\u503c\uff09\u3002\u5f53 VaryByParam \u8bbe\u7f6e\u4e3a none \u65f6\uff0c\u5c06\u4e0d\u8003\u8651\u4efb\u4f55\u53c2\u6570\uff1b\u65e0\u8bba\u63d0\u4f9b\u4ec0\u4e48\u9644\u52a0\u53c2\u6570\uff0c\u90fd\u5c06\u5411\u6240\u6709\u7528\u6237\u53d1\u9001\u76f8\u540c\u7684\u9875\u3002\u5c06 VaryByParam \u8bbe\u7f6e\u4e3a *\uff08\u661f\u53f7\uff09\u8868\u660e\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u552f\u4e00\u7684\u8bf7\u6c42\u53c2\u6570\u7ec4\u5408\uff0c\u5c06\u7f13\u5b58\u4e00\u4e2a\u552f\u4e00\u9875\u3002\u4f46\u662f\uff0c\u5c06 VaryByParam \u8bbe\u7f6e\u4e3a * \u4f1a\u7f13\u5b58\u9875\u7684\u8bb8\u591a\u4e0d\u540c\u7248\u672c\uff0c\u6240\u4ee5\u5982\u679c\u60a8\u77e5\u9053\u7f13\u5b58\u53d8\u5316\u6240\u4f9d\u636e\u7684\u53c2\u6570\uff0c\u5efa\u8bae\u60a8\u5728 VaryByParam \u5c5e\u6027\u4e2d\u663e\u5f0f\u6307\u5b9a\u8fd9\u4e9b\u53c2\u6570\u3002\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1 \u7f13\u5b58\u9875\u7684\u591a\u4e2a\u7248\u672c\u3002<\/p>\n<p>\u5728 Web.config \u6587\u4ef6\u4e2d\u8bbe\u7f6e\u7f13\u5b58\u914d\u7f6e <br \/>\u9664\u4e86\u524d\u9762\u90e8\u5206\u4e2d\u7f51\u9875\u7684 OutputCache \u58f0\u660e\u5916\uff0c\u60a8\u9700\u8981\u5728 Web.config \u6587\u4ef6\u4e2d\u6307\u5b9a\u7f13\u5b58\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<p>\u521b\u5efa\u548c\u66f4\u65b0 Web.config \u6587\u4ef6<br \/>\u5982\u679c\u60a8\u7684\u7f51\u7ad9\u5df2\u5177\u6709 Web.config \u6587\u4ef6\uff0c\u8bf7\u8f6c\u81f3\u6b65\u9aa4 4\u3002<\/p>\n<p>\u5728\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u4e2d\uff0c\u53f3\u51fb\u7f51\u7ad9\u7684\u540d\u79f0\uff0c\u7136\u540e\u5355\u51fb&ldquo;\u6dfb\u52a0\u65b0\u9879&rdquo;\u3002<\/p>\n<p>\u5728&ldquo;\u6dfb\u52a0\u9879&rdquo;\u5bf9\u8bdd\u6846\u4e2d\uff0c\u5355\u51fb&ldquo;Web \u914d\u7f6e\u6587\u4ef6&rdquo;\uff0c\u7136\u540e\u5355\u51fb&ldquo;\u6dfb\u52a0&rdquo;\u3002<\/p>\n<p>\u8bf7\u786e\u4fdd\u4f7f\u7528\u540d\u79f0 Web.config\u3002<\/p>\n<p>\u5c06\u4e0b\u9762\u7684 XML \u4f5c\u4e3a system.web \u5143\u7d20\u7684\u5b50\u7ea7\u6dfb\u52a0\u5230 Web.config \u6587\u4ef6\u4e2d\uff1a<\/p>\n<p>\u590d\u5236\u4ee3\u7801<br \/>&lt;!-- caching section group --&gt;<br \/>&lt;caching&gt;<br \/>&lt;sqlCacheDependency enabled = &quot;true&quot; pollTime = &quot;1000&quot; &gt;<br \/>&lt;databases&gt;<br \/>&lt;add name=&quot;Northwind&quot; <br \/>connectionStringName=&quot;NorthwindConnectionString1&quot;<br \/>pollTime = &quot;1000&quot;<br \/>\/&gt;<br \/>&lt;\/databases&gt;<br \/>&lt;\/sqlCacheDependency&gt;<br \/>&lt;\/caching&gt;<br \/>\u6ce8\u610f <br \/>\u524d\u9762\u60a8\u5728\u521b\u5efa\u6570\u636e\u8fde\u63a5\u65f6\uff0c\u5df2\u5efa\u7acb\u4e86\u8fde\u63a5\u5b57\u7b26\u4e32\u540d\u79f0 NorthwindConnectionString1\u3002\u5982\u679c\u60a8\u7684\u8fde\u63a5\u5b57\u7b26\u4e32\u5177\u6709\u4e0d\u540c\u7684\u540d\u79f0\uff0c\u8bf7\u66ff\u6362\u4e3a\u8be5\u540d\u79f0\u3002 <\/p>\n<p>\u6ce8\u610f <br \/>\u5728\u8fde\u63a5\u5b57\u7b26\u4e32\u4e2d\u6307\u5b9a\u7684\u5e10\u6237\u51ed\u636e\u5fc5\u987b\u5177\u6709\u8db3\u591f\u7684\u7279\u6743\u6765\u8f6e\u8be2\u6570\u636e\u5e93\u3002 <\/p>\n<p>\u4fdd\u5b58\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u5176\u5173\u95ed\u3002<\/p>\n<p>\u6d4b\u8bd5\u4f7f\u7528\u7f13\u5b58\u529f\u80fd\u7684\u9875 <br \/>\u542f\u7528\u7f13\u5b58\u540e\uff0c\u5237\u65b0\u9875\u65f6\u5c06\u4e0d\u518d\u5bfc\u81f4\u65f6\u95f4\u6233\u6216\u6570\u636e\u5e93\u67e5\u8be2\u66f4\u65b0\uff0c\u56e0\u4e3a ASP.NET \u5c06\u4ece\u7f13\u5b58\u4e2d\u6ee1\u8db3\u9875\u8bf7\u6c42\u3002<\/p>\n<p>\u6d4b\u8bd5\u4f7f\u7528\u7f13\u5b58\u529f\u80fd\u7684\u9875<br \/>\u6309 Ctrl+F5 \u8fd0\u884c\u8be5\u9875\u3002<\/p>\n<p>\u6ce8\u610f\uff0c\u65f6\u95f4\u6233\u5728\u6bcf\u6b21\u9875\u5237\u65b0\u65f6\u4fdd\u6301\u4e0d\u53d8\u3002\u5c06\u4ece\u7f13\u5b58\u4e2d\u68c0\u7d22\u9875\u3002<\/p>\n<p>\u66f4\u6539\u6570\u636e <br \/>\u73b0\u5728\u53ef\u4ee5\u66f4\u6539\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u53ef\u770b\u5230\u7f13\u5b58\u88ab\u9a8c\u8bc1\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u9875\u3002 <\/p>\n<p>\u66f4\u6539\u6570\u636e<br \/>\u5728&ldquo;\u670d\u52a1\u5668\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\uff08Visual Web Developer \u901f\u6210\u7248\u4e2d\u4e3a&ldquo;\u6570\u636e\u5e93\u8d44\u6e90\u7ba1\u7406\u5668&rdquo;\u4e2d\uff09\uff0c\u5c55\u5f00&ldquo;\u6570\u636e\u8fde\u63a5&rdquo;\u8282\u70b9\u3002<\/p>\n<p>\u5c55\u5f00\u60a8\u5148\u524d\u521b\u5efa\u7684\u8fde\u63a5\u3002<\/p>\n<p>\u5c55\u5f00&ldquo;\u8868&rdquo;\u8282\u70b9\u3002<\/p>\n<p>\u53f3\u51fb&ldquo;Employees&rdquo;\uff0c\u7136\u540e\u5355\u51fb&ldquo;\u663e\u793a\u8868\u6570\u636e&rdquo;\u3002<\/p>\n<p>\u901a\u8fc7\u7f16\u8f91\u6570\u636e\u8868\u4e2d\u7684\u4efb\u4f55\u5b57\u6bb5\u5e76\u786e\u4fdd\u5b83\u662f\u7f51\u9875\u6240\u663e\u793a\u7684\u5b57\u6bb5\u6765\u66f4\u65b0\u6570\u636e\u5e93\u3002<\/p>\n<p>\u6216\u8005\u4e5f\u53ef\u4ee5\u4f7f\u7528 SQL \u7a97\u683c\uff08\u5982\u679c SQL \u7a97\u683c\u4e0d\u53ef\u89c1\uff0c\u5219\u5728&ldquo;\u67e5\u8be2\u8bbe\u8ba1\u5668&rdquo;\u83dc\u5355\u4e2d\u5355\u51fb&ldquo;\u7a97\u683c&rdquo;\uff0c\u7136\u540e\u5355\u51fb&ldquo;SQL&rdquo;\uff09\u3002\u76f4\u63a5\u8f93\u5165 SQL \u547d\u4ee4\uff0c\u7136\u540e\u5355\u51fb&ldquo;\u67e5\u8be2\u8bbe\u8ba1\u5668&rdquo;\u5de5\u5177\u680f\u4e2d\u7684&ldquo;\u6267\u884c SQL&rdquo;\u6309\u94ae\u3002\u4f8b\u5982\uff0c\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a<\/p>\n<p>\u590d\u5236\u4ee3\u7801<br \/>UPDATE dbo.Employees SET LastName = &#39;Doe&#39; WHERE (EmployeeID = 5)<\/p>\n<p>\u8fd9\u5c06\u628a\u96c7\u5458 5 \u7684\u540d\u79f0\u66f4\u6539\u4e3a Doe\u3002<\/p>\n<p>\u5173\u95ed\u6570\u636e\u7684\u89c6\u56fe\u3002<\/p>\n<p>\u6d4b\u8bd5 SQL \u7f13\u5b58\u4f9d\u8d56\u9879 <br \/>\u73b0\u5728\u53ef\u4ee5\u6d4b\u8bd5\u9875\uff0c\u4ee5\u67e5\u770b\u6570\u636e\u548c\u65f6\u95f4\u6233\u662f\u5426\u5df2\u66f4\u6539\u3002<\/p>\n<p>\u6d4b\u8bd5 SQL \u7f13\u5b58\u4f9d\u8d56\u9879<br \/>\u6309 Ctrl+F5 \u8fd0\u884c\u8be5\u9875\u3002<\/p>\n<p>\u6ce8\u610f\uff0c\u65f6\u95f4\u6233\u5df2\u66f4\u6539\uff0c\u5e76\u663e\u793a\u65b0\u6570\u636e\u3002<\/p>\n<p>\u6309 Ctrl+F5 \u518d\u6b21\u8fd0\u884c\u8be5\u9875\u3002<\/p>\n<p>\u8fd9\u6b21\u65f6\u95f4\u6233\u4fdd\u6301\u4e0d\u53d8\uff0c\u56e0\u4e3a\u6570\u636e\u672a\u66f4\u6539\uff0c\u5e76\u4e14\u73b0\u5728\u6b63\u4ece\u7f13\u5b58\u4e2d\u518d\u6b21\u68c0\u7d22\u8be5\u9875<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6b64\u6f14\u7ec3\u6f14\u793a\u5982\u4f55\u7f13\u5b58\u4f9d\u8d56\u4e8e SQL Server \u6570\u636e\u5e93\u4e2d\u6570\u636e\u7684 ASP.NET \u9875\u3002<\/p>\n<p>ASP.NET \u8f93\u51fa\u7f13\u5b58\u7684\u4e00\u9879\u9ad8\u7ea7\u529f\u80fd\u662f SQL \u7f13\u5b58\u4f9d\u8d56\u9879\u3002SQL \u7f13\u5b58\u4f9d\u8d56\u9879\u4f7f\u60a8\u53ef\u4ee5\u7f13\u5b58\u4f9d\u8d56\u4e8e SQL Server \u8868\u4e2d\u6570\u636e\u7684\u9875\u3002\u60a8\u53ef\u4ee5\u914d\u7f6e SQL Server \u548c ASP.NET \u4ee5\u7f13\u5b58\u9875\u8bf7\u6c42\uff0c\u964d\u4f4e\u670d\u52a1\u5668\u5de5\u4f5c\u8d1f\u8377\uff0c\u76f4\u5230\u9875\u6240\u4f9d\u8d56\u7684\u6570\u636e\u5df2\u5728 SQL Server \u4e2d\u66f4\u65b0\u4e3a\u6b62\u3002\u5bf9\u4e8e\u76f8\u5bf9\u4fdd\u6301\u9759\u6001\u7684\u4ea7\u54c1\u76ee\u5f55\u6216\u5ba2\u6237\u6ce8...<\/p>\n<p> <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/112\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[273],"tags":[16,25],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-article","tag-C","tag-SQLServer"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}