﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-杨的空间-随笔分类-技术类</title><link>http://www.cnitblog.com/yhf119/category/1890.html</link><description>业精于勤，荒于嬉，行成于思，毁于随</description><language>zh-cn</language><lastBuildDate>Tue, 27 Sep 2011 11:06:46 GMT</lastBuildDate><pubDate>Tue, 27 Sep 2011 11:06:46 GMT</pubDate><ttl>60</ttl><item><title>asp.net C# 中的 Excel 操作</title><link>http://www.cnitblog.com/yhf119/archive/2008/01/16/38927.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Wed, 16 Jan 2008 06:43:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2008/01/16/38927.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/38927.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2008/01/16/38927.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/38927.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/38927.html</trackback:ping><description><![CDATA[<p><strong>连接字符串：<br></strong></p>
<p>Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""</p>
<br>Microsoft Jet 提供程序用于连接到 Excel 工作簿。在以下连接字符串中，Extended Properties 关键字设置 Excel 特定的属性。<br>HDR=Yes;指示第一行中包含列名，而不是数据，<br>IMEX=1;通知驱动程序始终将&#8220;互混&#8221;数据列作为文本读取。<br><br>
<img src ="http://www.cnitblog.com/yhf119/aggbug/38927.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2008-01-16 14:43 <a href="http://www.cnitblog.com/yhf119/archive/2008/01/16/38927.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C# 使用 GetOleDbSchemaTable 检索架构信息(表、列、主键等)</title><link>http://www.cnitblog.com/yhf119/archive/2008/01/16/38926.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Wed, 16 Jan 2008 06:19:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2008/01/16/38926.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/38926.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2008/01/16/38926.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/38926.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/38926.html</trackback:ping><description><![CDATA[本文演示如何用 ADO.NET 中 <strong>OleDbConnection</strong> 对象的 <strong>GetOleDbSchemaTable</strong> 方法检索数据库架构信息。数据源中的架构信息包括数据库或可通过数据库中的数据源、表和视图得到的目录以及所存在的约束等。表中的架构信息包括主键、列和自动编号字段。<br><br>注意，在使用<strong> SqlClient.SqlConnection </strong>对象时没有与 <strong>GetOleDbSchemaTable</strong> 等价的方法。SQL Server .NET 数据提供程序通过存储过程和信息性视图展示后端架构信息。有关可通过 Microsoft SQL Server 得到的视图和存储过程的更多信息，请参见 MSDN 库中的 Transact-SQL 参考。 <br>
<h3 id=tocHeadRef>OleDbConnection 对象的 GetOleDbSchemaTable 方法</h3>
<script type=text/javascript>loadTOCNode(2, 'summary');</script>
OLE DB .NET 数据提供程序使用 <strong>OleDbConnection</strong> 对象的 <strong>GetOleDbSchemaTable</strong> 方法展示架构信息。<strong>GetOleDbSchemaTable</strong> 返回填充了架构信息的 <strong>DataTable</strong>。<br><br><strong>GetOleDbSchemaTable</strong> 的第一个参数是架构参数，它是一个<strong> OleDbSchemaGuid</strong> 类型的标识，指定了要返回的架构信息的类型（如表、列和主键）。第二个参数是一个限制对象数组，对 <strong>DataTable</strong> 架构中返回的行进行过滤（例如，您可以指定对表的名称、类型、所有者和/或架构的限制）。 <br><br><span><a id=3a></a></span>
<h4 id=tocHeadRef>OleDbSchemaGuid 成员</h4>
<script type=text/javascript>loadTOCNode(3, 'summary');</script>
<strong>OleDbSchemaGuid</strong> 参数指定 <strong>GetOleDbSchemaTable</strong> 方法要返回的架构表的类型。 <strong>OleDbSchemaGuid</strong> 成员主要包括：
<table class="list ul">
    <tbody>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>列</td>
        </tr>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>外键</td>
        </tr>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>索引</td>
        </tr>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>主键</td>
        </tr>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>表</td>
        </tr>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>视图 </td>
        </tr>
    </tbody>
</table>
有关<strong> OleDbSchemaGuid </strong>成员的完整列表，请参见<span><a href="http://support.microsoft.com/kb/309681/zh-cn#8"><u><font color=#800080>参考</font></u></a></span>部分的"OleDbSchemaGuid Members"Web 站点。 <br><br><span><a id=3b></a></span>
<h4 id=tocHeadRef>限制</h4>
<script type=text/javascript>loadTOCNode(3, 'summary');</script>
限制是一个过滤值对象数组，每个元素对应于结果 <strong>DataTable</strong> 中的一个 <strong>DataColumn</strong>。<strong>OleDbSchemaGuid</strong> 参数决定了相应的限制。例如，在指定表的<strong> OleDbSchemaGuid </strong>时，限制数组如下所示：
<div class=indent>{TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE} </div>
若要查看可用的限制，请单击以下 Microsoft Web 站点中的任一<strong> OleDbSchemaGuid </strong>成员：
<div class=indent>OleDbSchemaGuid 成员<br><span class=ll><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbschemaguidmemberstopic.asp"><u><font color=#0000ff>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbschemaguidmemberstopic.asp </font></u></a></span><span class=pLink>(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbschemaguidmemberstopic.asp)</span></div>
在传递限制数组的值时，对于不包含值的数组元素使用 Visual C# .NET 的<strong> null </strong>关键字。例如，如果要检索表的架构，使用<strong> OleDbSchemaGuid.Tables</strong>。但是，如果指定了表，也将返回别名、同义词、视图和其他相关对象。因此，如果您希望过滤掉除表以外的所有其他对象，请对 TABLE_TYPE 使用 TABLE 限制。可以对 TABLE_CATALOG、TABLE_SCHEMA 和 TABLE_NAME 使用<strong> null</strong>，因为您不过滤这些对象： <code>
<pre class=code>schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new Object[] {null, null, null, "TABLE"});</pre>
</code><span><a id=3c></a></span>
<h4 id=tocHeadRef>返回的数据表</h4>
<script type=text/javascript>loadTOCNode(3, 'summary');</script>
每个符合<strong> OleDbSchemaGuid </strong>类型和限制规则的对象都对应于<strong> GetOleDbSchemaTable </strong>方法返回的<strong> DataTable </strong>中的一行。每个限制列对应于<strong> DataTable </strong>的一列，后面是基于<strong> OleDbSchemaGuid </strong>字段的其他架构信息。<br><br>例如，当您使用以下代码时，返回的<strong> DataTable </strong>的每一行是一个数据库表： <code>
<pre class=code>schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new Object[] {null, null, null, "TABLE"});</pre>
</code><font face="宋体, MS Song"><strong>DataTable </strong>中返回的每一列是限制列（TABLE_CATALOG、TABLE_SCHEMA、TABLE_NAME、TABLE_TYPE），后面是 TABLE_GUID、DESCRIPTION、TABLE_PROPID、DATE_CREATED 和 DATE_MODIFIED 的其他架构列。<br><br>若要获得列名称的列表（即字段描述符，如 TABLE_CATALOG、TABLE_SCHEMA 和 TABLE_NAME），您可以使用列的位置顺序。注意<strong> Columns </strong>数组的元素下标是从 0 开始的： </font><code>
<pre class=code>for (int i = 0; i &lt; schemaTable.Columns.Count; i++) {
Console.WriteLine(schemaTable.Columns[i].ToString());
}</pre>
</code><font face="宋体, MS Song">若要获得每一列的值（即实际的表名称，如 Categories、Customers 和 Employees），您可以使用该行的<strong> ItemArray </strong>的位置顺序。注意<strong> ItemArray </strong>数组的元素下标是从 0 开始的： </font><code>
<pre class=code>for (int i = 0; i &lt; schemaTable.Rows.Count; i++) {
Console.WriteLine(schemaTable.Rows[i].ItemArray[2].ToString());
}</pre>
</code><span><a id=4></a></span>
<p class=topOfPage><a href="http://support.microsoft.com/kb/309681/zh-cn#top"><img alt="" src="http://support.microsoft.com/library/images/support/en-us/uparrow.gif"><u><font color=#800080>回到顶端</font></u></a></p>
<h3 id=tocHeadRef>创建列出数据库中的表的示例</h3>
<script type=text/javascript>loadTOCNode(2, 'summary');</script>
以下示例列出 SQL Server Northwind 数据库中的表。<br><br><strong>OleDbSchemaGuid.Tables</strong> 将返回那些可由特定登录访问的表（包括视图）。如果指定对象数组 {null, null, null, "TABLE"}，那么您的过滤结果只包括 TABLE 的 TABLE_TYPE。然后在返回的架构表中的每一行列出表名称 (TABLE_NAME)。
<table class="list ol">
    <tbody>
        <tr>
            <td class=number>1.</td>
            <td class=text>启动 Visual Studio .NET。</td>
        </tr>
        <tr>
            <td class=number>2.</td>
            <td class=text>新建一个 Visual C# 控制台应用程序项目。默认情况下，Class1.cs 将添加到项目中。</td>
        </tr>
        <tr>
            <td class=number>3.</td>
            <td class=text>打开 Class1 的代码窗口。将下面的代码粘贴到代码窗口的顶部，位于 <strong>namespace</strong> 声明之上： <code>
            <pre class=code>using System.Data;
            using System.Data.OleDb;</pre>
            </code></td>
        </tr>
        <tr>
            <td class=number>4.</td>
            <td class=text>在代码窗口中，将下面的代码粘贴到 <strong>Main</strong> 函数中： <code>
            <pre class=code>OleDbConnection cn = new OleDbConnection();
            DataTable schemaTable;
            //Connect to the Northwind database in SQL Server.
            //Be sure to use an account that has permission to list tables.
            cn.ConnectionString = "Provider=SQLOLEDB;Data Source=server;User ID=sa;
            Password=password;Initial Catalog=Northwind";
            cn.Open();
            //Retrieve schema information about tables.
            //Because tables include tables, views, and other objects,
            //restrict to just TABLE in the Object array of restrictions.
            schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
            new Object[] {null, null, null, "TABLE"});
            //List the table name from each row in the schema table.
            for (int i = 0; i &lt; schemaTable.Rows.Count; i++) {
            Console.WriteLine(schemaTable.Rows[i].ItemArray[2].ToString());
            }
            //Explicitly close - don't wait on garbage collection.
            cn.Close();
            //Pause
            Console.ReadLine();</pre>
            </code></td>
        </tr>
        <tr>
            <td class=number>5.</td>
            <td class=text>修改 <strong>ConnectionString</strong>，以使用在罗斯文 (Northwind) 数据库中具有列表权限的帐户连接到您的 SQL Server 计算机。</td>
        </tr>
        <tr>
            <td class=number>6.</td>
            <td class=text>按 F5 键编译并运行该项目。您会注意到表已列在控制台窗口中。</td>
        </tr>
        <tr>
            <td class=number>7.</td>
            <td class=text>按 ENTER 键结束控制台应用程序并回到集成开发环境 (IDE)。 </td>
        </tr>
    </tbody>
</table>
<span><a id=5></a></span>
<p class=topOfPage><a href="http://support.microsoft.com/kb/309681/zh-cn#top"><img alt="" src="http://support.microsoft.com/library/images/support/en-us/uparrow.gif"><u><font color=#800080>回到顶端</font></u></a></p>
<h3 id=tocHeadRef>创建检索表的架构的示例</h3>
<script type=text/javascript>loadTOCNode(2, 'summary');</script>
以下示例列出 SQL Server Northwind 数据库中 Employees 表的架构信息。<br><br><strong>OleDbSchemaGuid.Tables</strong> 将返回那些可由特定登录访问的表（包括视图）。如果指定对象数组 {null, null, "Employees", "TABLE"}，那么您的过滤结果只包括名为 Employees 的表。然后列出返回的架构表的架构信息。
<table class="list ol">
    <tbody>
        <tr>
            <td class=number>1.</td>
            <td class=text>新建一个 Visual C# 控制台应用程序项目。默认情况下，Class1.cs 将添加到项目中。</td>
        </tr>
        <tr>
            <td class=number>2.</td>
            <td class=text>打开 Class1 的代码窗口。将下面的代码粘贴到代码窗口的顶部，位于 <strong>namespace</strong> 声明之上： <code>
            <pre class=code>using System.Data;
            using System.Data.OleDb;</pre>
            </code></td>
        </tr>
        <tr>
            <td class=number>3.</td>
            <td class=text>在代码窗口中，将下面的代码粘贴到 <strong>Main</strong> 函数中： <code>
            <pre class=code>OleDbConnection cn = new OleDbConnection();
            DataTable schemaTable;
            //Connect to the Northwind database in SQL Server.
            //Be sure to use an account that has permission to retrieve table schema.
            cn.ConnectionString = "Provider=SQLOLEDB;Data Source=server;User ID=sa;
            Password=password;Initial Catalog=Northwind";
            cn.Open();
            //Retrieve schema information about the Employees table.
            schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
            new Object[] {null, null, "Employees", "TABLE"});
            //List the schema info for the Employees table
            //in the format Field Descriptor :Field Value.
            for (int i = 0; i &lt; schemaTable.Columns.Count; i++) {
            Console.WriteLine(schemaTable.Columns[i].ToString() + " : " +
            schemaTable.Rows[0][i].ToString());
            }
            //Explicitly close - don't wait on garbage collection.
            cn.Close();
            //Pause
            Console.ReadLine();</pre>
            </code></td>
        </tr>
        <tr>
            <td class=number>4.</td>
            <td class=text>修改 <strong>ConnectionString</strong>，以使用具有检索 Employees 表架构权限的帐户连接到您的 SQL Server 计算机。</td>
        </tr>
        <tr>
            <td class=number>5.</td>
            <td class=text>按 F5 键编译并运行该项目。您会注意到表已列在控制台窗口中。</td>
        </tr>
        <tr>
            <td class=number>6.</td>
            <td class=text>按 ENTER 键结束控制台应用程序并回到 IDE。 </td>
        </tr>
    </tbody>
</table>
<span><a id=6></a></span>
<p class=topOfPage><a href="http://support.microsoft.com/kb/309681/zh-cn#top"><img alt="" src="http://support.microsoft.com/library/images/support/en-us/uparrow.gif"><u><font color=#800080>回到顶端</font></u></a></p>
<h3 id=tocHeadRef>创建列出表中的列的示例</h3>
<script type=text/javascript>loadTOCNode(2, 'summary');</script>
以下示例列出 SQL Server Northwind 数据库中 Employees 表中的列名称。<br><br><strong>OleDbSchemaGuid.Columns </strong>将返回那些可由特定登录访问的表和视图中的列。如果指定对象数组 {null, null, "Employees", null}，您的过滤结果只包括 Employees 表中的列。
<table class="list ol">
    <tbody>
        <tr>
            <td class=number>1.</td>
            <td class=text>新建一个 Visual C# 控制台应用程序项目。默认情况下，Class1.cs 将添加到项目中。</td>
        </tr>
        <tr>
            <td class=number>2.</td>
            <td class=text>打开 Class1 的代码窗口。将下面的代码粘贴到代码窗口的顶部，位于 <strong>namespace</strong> 声明之上： <code>
            <pre class=code>using System.Data;
            using System.Data.OleDb;</pre>
            </code></td>
        </tr>
        <tr>
            <td class=number>3.</td>
            <td class=text>在代码窗口中，将下面的代码粘贴到 <strong>Main</strong> 函数中： <code>
            <pre class=code>OleDbConnection cn = new OleDbConnection();
            DataTable schemaTable;
            //Connect to the Northwind database in SQL Server.
            //Be sure to use an account that has permission to list the columns in the Employees table.
            cn.ConnectionString = "Provider=SQLOLEDB;Data Source=server;User ID=sa;
            Password=password;Initial Catalog=Northwind";
            cn.Open();
            //Retrieve schema information about columns.
            //Restrict to just the Employees TABLE.
            schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
            new Object[] {null, null, "Employees", null});
            //List the column name from each row in the schema table.
            for (int i = 0; i &lt; schemaTable.Rows.Count; i++) {
            Console.WriteLine(schemaTable.Rows[i].ItemArray[3].ToString());
            }
            //Explicitly close - don't wait on garbage collection.
            cn.Close();
            //Pause
            Console.ReadLine();</pre>
            </code></td>
        </tr>
        <tr>
            <td class=number>4.</td>
            <td class=text>修改 <strong>ConnectionString</strong>，以使用具有列出 Employees 表中各列的权限的帐户连接到您的 SQL Server 计算机。</td>
        </tr>
        <tr>
            <td class=number>5.</td>
            <td class=text>按 F5 键编译并运行该项目。您会注意到 Employees 表中的列已列在控制台窗口中。</td>
        </tr>
        <tr>
            <td class=number>6.</td>
            <td class=text>按 ENTER 键结束控制台应用程序并回到 IDE。 </td>
        </tr>
    </tbody>
</table>
<span><a id=7></a></span>
<p class=topOfPage><a href="http://support.microsoft.com/kb/309681/zh-cn#top"><img alt="" src="http://support.microsoft.com/library/images/support/en-us/uparrow.gif"><u><font color=#800080>回到顶端</font></u></a></p>
<h3 id=tocHeadRef>创建列出表中的主键的示例</h3>
<script type=text/javascript>loadTOCNode(2, 'summary');</script>
以下示例列出 SQL Server Northwind 数据库的 Employees 表和 SQL Server Pubs 数据库的 Employee 表中的主键。<br><br><strong>OleDbSchemaGuid.Primary_Keys </strong>将返回那些可由特定登录访问的目录中的主键。在此示例中，<strong>OleDbConnection </strong>连接到 SQL Server，而不是连接到特定的 SQL Server 数据库： <code>
<pre class=code>cn.ConnectionString = "Provider=SQLOLEDB;Data Source=server;User ID=sa;
Password=password;"</pre>
</code><font face="宋体, MS Song">因为，罗斯文或 Pubs 数据库将在限制数组的 TABLE_CATALOG 中指定。此代码指定表的所有者"dbo"作为 TABLE_SCHEMA 限制。此外，代码还指定了 TABLE_NAME 限制的表名称。<br><br>若要获得罗斯文数据库中 Employees 表的主键，您可以使用 {"Northwind", "dbo", "Employees"} 对象数组： </font><code>
<pre class=code>schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys,
new Object[] {"Northwind", "dbo", "Employees"});</pre>
</code><br><font face="宋体, MS Song">若要获得 Pubs 数据库中 Employee 表的主键，您可以使用 {"Pubs", "dbo", "Employee"} 对象数组： </font><code>
<pre class=code>schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys,
new Object[] {"Pubs", "dbo", "Employee"});</pre>
</code><font face="宋体, MS Song">若要创建示例，可以按照下列步骤进行： </font>
<table class="list ol">
    <tbody>
        <tr>
            <td class=number>1.</td>
            <td class=text>新建一个 Visual C# 控制台应用程序项目。默认情况下，Class1.cs 将添加到项目中。</td>
        </tr>
        <tr>
            <td class=number>2.</td>
            <td class=text>打开 Class1 的代码窗口。将下面的代码粘贴到代码窗口的顶部，位于 <strong>namespace</strong> 声明之上： <code>
            <pre class=code>using System.Data;
            using System.Data.OleDb;</pre>
            </code></td>
        </tr>
        <tr>
            <td class=number>3.</td>
            <td class=text>在代码窗口中，将下面的代码粘贴到 <strong>Main</strong> 函数中： <code>
            <pre class=code>OleDbConnection cn = new OleDbConnection();
            DataTable schemaTable;
            //Connect to SQL Server.
            //Be sure to use an account that has permissions to list primary keys
            //in both the Northwind and Pubs databases.
            cn.ConnectionString = "Provider=SQLOLEDB;Data Source=server;User ID=sa;
            Password=password;";
            cn.Open();
            //Retrieve schema information about primary keys.
            //Restrict to just the Employees TABLE in the Northwind CATALOG.
            schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys,
            new Object[] {"Northwind", "dbo", "Employees"});
            //List the primary key for the first row in the schema table.
            //The first three items in the ItemArray in the row are catalog, schema, and table.
            //The fourth item is the primary key.
            Console.WriteLine(schemaTable.Rows[0].ItemArray[3].ToString());
            //Retrieve primary key for the Employee TABLE in the Pubs CATALOG.
            schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys,
            new Object[] {"Pubs", "dbo", "Employee"});
            //List the primary key for the first row in the schema table.
            Console.WriteLine(schemaTable.Rows[0].ItemArray[3].ToString());
            //Explicitly close - don't wait on garbage collection.
            cn.Close();
            //Pause
            Console.ReadLine();</pre>
            </code></td>
        </tr>
        <tr>
            <td class=number>4.</td>
            <td class=text>修改 <strong>ConnectionString</strong>，以使用具有足够权限可列出主键的帐户连接到您的 SQL Server 计算机。</td>
        </tr>
        <tr>
            <td class=number>5.</td>
            <td class=text>按 F5 键编译并运行该项目。您会注意到罗斯文数据库和 Pubs 数据库的 Employee 表的主键已列在控制台窗口中。</td>
        </tr>
        <tr>
            <td class=number>6.</td>
            <td class=text>按 ENTER 键结束控制台应用程序并回到 IDE。 </td>
        </tr>
    </tbody>
</table>
<p><br>出处：<a href="http://support.microsoft.com/kb/309681/zh-cn">http://support.microsoft.com/kb/309681/zh-cn</a><br></p>
<p>&nbsp;</p>
<img src ="http://www.cnitblog.com/yhf119/aggbug/38926.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2008-01-16 14:19 <a href="http://www.cnitblog.com/yhf119/archive/2008/01/16/38926.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WEB服务器安全设置</title><link>http://www.cnitblog.com/yhf119/archive/2008/01/11/38759.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Fri, 11 Jan 2008 08:38:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2008/01/11/38759.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/38759.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2008/01/11/38759.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/38759.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/38759.html</trackback:ping><description><![CDATA[一、操作系统配置<br><br>1.安装操作系统(NTFS分区)后，装杀毒软件，我选用的是卡巴。<br><br>2.安装系统补丁。扫描漏洞全面杀毒<br><br>3.删除Windows Server 2003默认共享<br>首先编写如下内容的批处理文件：<br>@echo off<br>net share C$ /del<br>net share D$ /del<br>net share E$ /del<br>net share F$ /del<br>net share admin$ /del<br>文件名为delshare.bat，放到启动项中，每次开机时会自动删除共享。<br><br>4.禁用IPC连接<br>打开CMD后输入如下命令即可进行连接：net use\\ip\ipc$ "password" /user:"usernqme"。我们可以通过修改注册表来禁用IPC连接。打开注册表编辑器。找到如下组建HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa中的restrictanonymous子键，将其值改为1即可禁用IPC连接。<br><br>5.删除"网络连接"里的协议和服务<br>在"网络连接"里，把不需要的协议和服务都删掉，这里只安装了基本的Internet协议（TCP/IP），同时在高级tcp/ip设置里--"NetBIOS"设置"禁用tcp/IP上的NetBIOS（S）"。<br><br>6.启用windows连接防火墙，只开放web服务(80端口)。<br>注：在2003系统里，不推荐用TCP/IP筛选里的端口过滤功能，譬如在使用FTP服务器的时候，如果仅仅只开放21端口，由于FTP协议的特殊性，在进行FTP传输的时候，由于FTP 特有的Port模式和Passive模式，在进行数据传输的时候，需要动态的打开高端口，所以在使用TCP/IP过滤的情况下，经常会出现连接上后无法列出目录和数据传输的问题。所以在2003系统上增加的windows连接防火墙能很好的解决这个问题，所以都不推荐使用网卡的TCP/IP过滤功能。<br><br>7.磁盘权限<br>系统盘只给 Administrators 和 SYSTEM 权限<br>系统盘\Documents and Settings 目录只给 Administrators 和 SYSTEM 权限；<br>系统盘\Documents and Settings\All Users 目录只给 Administrators 和 SYSTEM 权限；<br>系统盘\Documents and Settings\All Users\Application Data目录只给 Administrators 和 SYSTEM 权限；<br>系统盘\Windows 目录只给 Administrators 、 SYSTEM 和 users 权限；<br>系统盘\Windows\System32\net.exe，net1.exe，cmd.exe，command.exe，ftp.exe，netstat.exe，regedit.exe，at.exe，attrib.exe，cacls.exe 文件只给 Administrators 权限(如果觉得没用就删了它，比如我删了cmd.exe，command.exe，嘿嘿。)；<br>其它盘，有安装程序运行的(我的sql server 2000 在D盘)给 Administrators 和 SYSTEM 权限，无只给 Administrators 权限。<br><br>8.本地安全策略设置<br>开始菜单—&gt;管理工具—&gt;本地安全策略<br>A、本地策略——&gt;审核策略 (可选用)<br>审核策略更改 成功 失败<br>审核登录事件 成功 失败<br>审核对象访问 失败<br>审核过程跟踪 无审核<br>审核目录服务访问 失败<br>审核特权使用 失败<br>审核系统事件 成功 失败<br>审核账户登录事件 成功 失败<br>审核账户管理 成功 失败<br><br>B、本地策略——&gt;用户权限分配<br>关闭系统：只有Administrators组、其它全部删除。<br>通过终端服务拒绝登陆：加入Guests、Users组<br>通过终端服务允许登陆：只加入Administrators，Remote Desktop Users，其他全部删除<br><br>C、本地策略——&gt;安全选项<br>交互式登陆：不显示上次的用户名 启用<br>网络访问：可匿名访问的共享 全部删除<br>网络访问：可匿名访问的命名管道 全部删除<br>**网络访问：可远程访问的注册表路径 全部删除<br>**网络访问：可远程访问的注册表路径和子路径 全部删除<br>帐户：重命名来宾帐户 重命名一个帐户<br>(下面一项更改可能导致sqlserver不能使用)<br>帐户：重命名系统管理员帐户 重命名一个帐户<br><br><br><br>二、iis配置(包括网站所在目录)<br><br>1.新建自己的网站(*注意：在应用程序设置中执行权限设为无，在需要的目录里再更改)，目录不在系统盘<br>注：为支持asp.net,将系统盘\Inetpub\wwwroot中的aspnet_client文件夹复制到web根目录下，并给web根目录加上users权限。<br><br>2.删掉系统盘\inetpub目录<br><br>3.删除不用的映射<br>在"应用程序配置"里，只给必要的脚本执行权限：ASP、ASPX。<br><br>4.为网站创建系统用户<br>A.例如：网站为yushan43436.net，新建用户yushan43436.net权限为guests。然后在web站点属性里"目录安全性"---"身份验证和访问控制"里设置匿名访问使用下列Windows 用户帐户"的用户名和密码都使用yushan43436.net这个用户的信息。(用户名：主机名\yushan43436.net)<br>B.给网站所在的磁盘目录添加用户yushan43436.net，只给读取和写入的权限。<br><br>5.设置应用程及子目录的执行权限<br>A.主应用程序目录中的"属性--应用程序设置--执行权限"设为纯脚本<br>B.在不需要执行asp、asp.net的子目录中，例如上传文件目录，执行权限设为无<br><br>6.应用程序池设置<br>我的网站使用的是默认应用程序池。设置"内存回收"：这里的最大虚拟内存为：1000M，最大使用的物理内存为256M，这样的设置几乎是没限制这个站点的性能的。<br>回收工作进程(分钟)：1440<br>在下列时间回收工作进程：06:00<br><br><br><br>三、sql server 2000 配置<br><br>1.密码设置<br>我编的程序用了sa用户，密码设置超复杂(自己记不住，保存在手机里，嘿嘿)。<br><br>2.删除危险的扩展存储过程和相关.dll。<br>Xp_cmdshell(这个肯定首当其冲，不用说了)、Xp_regaddmultistring、Xp_regdeletekey、Xp_regdeletevalue、Xp_regenumvalues、Xp_regread、Xp_regwrite、Xp_regremovemultistring<br><br><br>四、其它设置(可选用，本人可不负责)<br><br>1.任何用户密码都要复杂，不需要的用户---删。<br><br>2.防止SYN洪水攻击<br>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters<br>新建DWORD值，名为SynAttackProtect，值为2<br><br>3.禁止响应ICMP路由通告报文<br>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\interface<br>新建DWORD值，名为PerformRouterDiscovery 值为0<br><br>4.防止ICMP重定向报文的攻击<br>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters<br>将EnableICMPRedirects 值设为0<br><br>5.不支持IGMP协议<br>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters<br>新建DWORD值，名为IGMPLevel 值为0<br><br>6.禁用DCOM：<br>运行中输入 Dcomcnfg.exe。 回车，单击&#8220;控制台根节点&#8221;下的&#8220;组件服务&#8221;。打开&#8220;计算机&#8221;子文件夹。<br>对于本地计算机，请以右键单击&#8220;我的电脑&#8221;，然后选择&#8220;属性&#8221;。选择&#8220;默认属性&#8221;选项卡。<br>清除&#8220;在这台计算机上启用分布式 COM&#8221;复选框。 
<img src ="http://www.cnitblog.com/yhf119/aggbug/38759.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2008-01-11 16:38 <a href="http://www.cnitblog.com/yhf119/archive/2008/01/11/38759.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>javascript 中实现对象可改变尺寸(原标题：Make your DIVs Resizeable)</title><link>http://www.cnitblog.com/yhf119/archive/2007/12/01/37117.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Sat, 01 Dec 2007 02:32:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/12/01/37117.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/37117.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/12/01/37117.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/37117.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/37117.html</trackback:ping><description><![CDATA[<p>I love using Scriptaculous for its effects and drag/drop. However, I need to have my DIVs be resizable too. To make this happen, I&#8217;ve written a class called <strong>Resizeable</strong> that can be added to a DIV in the same way that <strong>Draggable</strong> can be.</p>
<p>This code is standalone (it needs Prototype, but not Scriptaculous), and it can be used with <strong>Draggable</strong> with one note: The <strong>Draggable</strong> handle cannot be the element that is <strong>Resizeable</strong>, you must specify a handle element when you create a <strong>Draggable</strong> to avoid confusion between <strong>Draggable</strong> and <strong>Resizeable</strong>.</p>
<p>This doesn&#8217;t work very well<br>...<br>...<br><code type="ruby">new Draggable(&#8216;foo&#8217;); new Resizeable(&#8216;foo&#8217;); <br>...<br>...</code></p>
<p>This works nicely:<br>...<br>...<code type="ruby">
<p>new Draggable(&#8216;foo&#8217;, {handle: &#8216;bar&#8217;}); new Resizeable(&#8216;foo&#8217;); </code></p>
<p>There aren&#8217;t many options for this object, but here they are:</p>
<p>The grab areas can be defined with <em>top</em>, <em>left</em>, <em>bottom</em>, <em>right</em>. Each defaults to 6 pixels. If you set this to 0 (zero), then resize in that direction will be disabled.<br><code type="ruby">... <br></code><code type="ruby">...</p>
<p>new Resizeable(&#8216;foo&#8217;, {top: 0, left:50} ); </code></p>
<p>A callback function can be defined that will be called when the resize is over.<br>...<br><code type="ruby">... </p>
<p>new Resizeable(&#8216;foo&#8217;, {resize: function(el) { alert(&#8216;Done!&#8217;); } } ); </code></p>
<p>The minimum height and width of the DIV can be specified as minHeight and minWidth options.</p>
<p><a href="http://blog.craz8.com/test-resize.html"><u><font color=#800080>The resizable code in action</font></u></a> &#8211; view source to see how it works.</p>
<p>The Javascript source file can be <a href="http://blog.craz8.com/files/resize.js"><u><font color=#800080>downloaded here</font></u></a></p>
<p>Currently, this code doesn&#8217;t quite work in IE (the DIV can jiggle around a little), but Firefox 1.0 is working Ok.</p>
<p><br>&nbsp;</p>
<p>出处：<a href="http://blog.craz8.com/articles/2005/12/01/make-your-divs-resizeable">http://blog.craz8.com/articles/2005/12/01/make-your-divs-resizeable</a></p>
<img src ="http://www.cnitblog.com/yhf119/aggbug/37117.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-12-01 10:32 <a href="http://www.cnitblog.com/yhf119/archive/2007/12/01/37117.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ASP.NET效率陷阱之--Attributes</title><link>http://www.cnitblog.com/yhf119/archive/2007/11/24/36829.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Sat, 24 Nov 2007 06:41:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/11/24/36829.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/36829.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/11/24/36829.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/36829.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/36829.html</trackback:ping><description><![CDATA[<font face=Tahoma>　　众所周知，在编写WebCustomControl时，继承于WebControl基类的Attributes以及其Attributes.CssStyle属性是十分常用和重要的。但就是这两个重要的属性，如果开发中使用不当却会带来莫名其妙的效率问题。<br><br>　　由于html的灵活性和不完备性，导致了WebControl基类没有完整的表现html元素所提供和支持的所有标签属性和CSS属性（当然由于不同browser的兼容问题，要提供完备的属性是不可能的）。又由于很多html标签属性和CSS属性都是很生僻的，很少或极少被使用，如果要完备的支持，反而会成为WebControl的负担。所以Attributes和Attributes.CssStyle这两个属性很好的解决了这个问题，当然这两个属性除了支持应有的html标签属性和CSS属性外，还支持任何合法的自定义key/value对。这里要讨论的问题就来之这个对自定义key/value对的支持上。<br><br>　　Attributes属性的类型是一个AttributeCollection，本来很自然的一个东西，可是不知道怎么搞得，AttributeCollection的构造函数却需要一个StateBag参数：</font>
<div align=center>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
<div align=left><font face=Tahoma><font size=3><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/24483552qs6o13i497et.gif" align=top></font><span style="COLOR: #0000ff">public</span></font><font face=Tahoma><span style="COLOR: #000000">&nbsp;AttributeCollection(StateBag&nbsp;bag)<br><img id=Codehighlighter1_41_66_Open_Image onclick="this.style.display='none'; Codehighlighter1_41_66_Open_Text.style.display='none'; Codehighlighter1_41_66_Closed_Image.style.display='inline'; Codehighlighter1_41_66_Closed_Text.style.display='inline';" src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/2048657388j352030b51.gif" align=top><img id=Codehighlighter1_41_66_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_41_66_Closed_Text.style.display='none'; Codehighlighter1_41_66_Open_Image.style.display='inline'; Codehighlighter1_41_66_Open_Text.style.display='inline';" src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/60122650vi0f3qu00974.gif" align=top></span><span id=Codehighlighter1_41_66_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/32274746j87rrs6nptx4.gif"></span></font><span id=Codehighlighter1_41_66_Open_Text><font face=Tahoma><span style="COLOR: #000000">{<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/414775344a209pfblm6t.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">._bag&nbsp;</span><span style="COLOR: #000000">=</span></font><span style="COLOR: #000000"><font face=Tahoma>&nbsp;bag;<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/8128733273v965nc18dr.gif" align=top>}</font></span></span></div>
</div>
</div>
<br><font face=Tahoma>　　这样的结果就是，Attributes和Attributes.CssStyle可能会被保存在ViewState中，事实上ASP.NET默认确实会保存其中的内容到ViewState中。<br><br>　　这种设计真的是让人觉得莫名其妙，在大家对ViewState效率问题的讨论中，觉得ViewState确实是鸡肋，用来保持一些服务器状态和数据让大家觉得方便也就算了。可是居然把和UI相关的内容都一股脑存到ViewState里，真的是疯狂。<br><br>　　下面是使用Attributes定义了一些自定义内容后的ViewState的情形：<br>
<p align=center><img alt=Attributes-ViewState.png src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/241005300zj24yy9rx78s.png" border=0></p>
<p align=center><em><font color=#808080>// AnalysisReport自定义控件上定义了一些自定的内容</font></em></p>
<p align=left>　　Attributes和Attributes.CssStyle被自动保存到ViewState中后，除了ViewState体积急增后，PostBack时Load ViewState的负担也同时增大了。上面这个事例中的页面PostBack的LoadState代价，如下图：</p>
<p align=center><img alt=LoadViewStateElapsed.png src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/36834213ot96o8c2ukt6s.png" border=0></p>
<p align=left>　　实际上我在编写控件时，从来没有想过要保持Attributes和Attributes.CssStyle，也没有想过要再次使用其中的数据。而且这个默认保存到ViewState的行为居然不能定制（至少我还没有发现），后来想到在ASP.NET页面生存期中，SaveState结束在PreRender中，所以在Render事件中使用Attributes和Attributes.CssStyle的就不会保存到ViewState中去。<br><br>　　修改代码：</p>
<p align=center></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
<div align=center><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/270550474sg9oe982242.gif" align=top><span style="COLOR: #0000ff">protected</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;OnPreRender(EventArgs&nbsp;e)<br><img id=Codehighlighter1_49_160_Open_Image onclick="this.style.display='none'; Codehighlighter1_49_160_Open_Text.style.display='none'; Codehighlighter1_49_160_Closed_Image.style.display='inline'; Codehighlighter1_49_160_Closed_Text.style.display='inline';" src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/67775646f0e5p80puc19.gif" align=top><img id=Codehighlighter1_49_160_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_49_160_Closed_Text.style.display='none'; Codehighlighter1_49_160_Open_Image.style.display='inline'; Codehighlighter1_49_160_Open_Text.style.display='inline';" src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/37075734iry7f18939sg.gif" align=top></span><span id=Codehighlighter1_49_160_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/720870326jd65ubw1b13.gif"></span><span id=Codehighlighter1_49_160_Open_Text><span style="COLOR: #000000">{<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/1261773025gzr399e72b.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Attributes[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abc</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">123</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/40086048c4t0n47782bq.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Attributes.CssStyle[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abc-style</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">123-style</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/02153614lmtnj0jk6c00.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">base</span><span style="COLOR: #000000">.OnPreRender(e);<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/113554029qpt7f6k7ehq.gif" align=top>}</span></span></div>
</div>
</font><br><font face=宋体>　　为如下形式：
<p>&#160;</p>
</font>
<p align=center></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><font face=宋体><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/420816681w056j8ej350.gif" align=top></font><span style="COLOR: #0000ff">protected</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">override</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;Render(HtmlTextWriter&nbsp;output)<br><img id=Codehighlighter1_54_164_Open_Image onclick="this.style.display='none'; Codehighlighter1_54_164_Open_Text.style.display='none'; Codehighlighter1_54_164_Closed_Image.style.display='inline'; Codehighlighter1_54_164_Closed_Text.style.display='inline';" src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/8570146728ftzf5o7o2t.gif" align=top><img id=Codehighlighter1_54_164_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_54_164_Closed_Text.style.display='none'; Codehighlighter1_54_164_Open_Image.style.display='inline'; Codehighlighter1_54_164_Open_Text.style.display='inline';" src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/63578640t585i2761f2f.gif" align=top></span><span id=Codehighlighter1_54_164_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/7277022180s7sxh7w47h.gif"></span><span id=Codehighlighter1_54_164_Open_Text><span style="COLOR: #000000">{<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/50557403k8a660z63dch.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Attributes[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abc</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">123</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/7121473381e89g4pplkk.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.Attributes.CssStyle[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">abc-style</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">123-style</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/3001337758l2132v8f0u.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;output.Write(Text);<br><img src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/71648454j66594tx02s0.gif" align=top>}</span></span></div>
<p>&#160;</p>
<p>　　就不会再将Attributes和Attributes.CssStyle保存到ViewState中了，上面那个AnalysisReport按上面的示例修改后，绑定同样数据的运行效果为：</p>
<p align=center><img alt=Attributes-ViewState02.png src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/146353736y816vq7yr07s.png" border=0></p>
<p>　　LoadState的代价也大大降低，其开销为：</p>
<p align=center><img alt=LoadViewStateElapsed02.png src="http://news.newhua.com/Newhua_Files/Net_pic/2007-3/19/1165402856vb2097tga6s.png" border=0></p>
<img src ="http://www.cnitblog.com/yhf119/aggbug/36829.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-11-24 14:41 <a href="http://www.cnitblog.com/yhf119/archive/2007/11/24/36829.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server 中日期操作的实用范例 </title><link>http://www.cnitblog.com/yhf119/archive/2007/11/12/36177.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Mon, 12 Nov 2007 09:06:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/11/12/36177.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/36177.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/11/12/36177.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/36177.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/36177.html</trackback:ping><description><![CDATA[<span class=a14c id=zoom>&nbsp;
<p style="TEXT-INDENT: 2em">
<center><strong>适合初学者学习的日期操作范例</strong></center>
<p style="TEXT-INDENT: 2em"><strong>1.显示本月第一天</strong>
<p style="TEXT-INDENT: 2em">
<center>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 59.64%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 42px; BACKGROUND-COLOR: #eeeeee">
<p align=left><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">DATEADD</span><span style="COLOR: #000000">(mm,</span><span style="COLOR: #ff00ff">DATEDIFF</span><span style="COLOR: #000000">(mm,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff00ff">getdate</span><span style="COLOR: #000000">()),</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">)<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;</span><span style="COLOR: #0000ff">select</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">convert</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #000000">datetime</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff00ff">convert</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">8</span><span style="COLOR: #000000">),</span><span style="COLOR: #ff00ff">getdate</span><span style="COLOR: #000000">(),&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">120</span><span style="COLOR: #000000">)</span><span style="COLOR: #808080">+</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">01</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">120</span><span style="COLOR: #000000">)</span></p>
</div>
</center><ccid_nobr></ccid_nobr>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>2.显示本月最后一天</strong>
<p style="TEXT-INDENT: 2em">
<center>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 59.78%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 58px; BACKGROUND-COLOR: #eeeeee">
<p align=left><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">select</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">dateadd</span><span style="COLOR: #000000">(</span><span style="COLOR: #ff00ff">day</span><span style="COLOR: #000000">,</span><span style="COLOR: #808080">-</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff00ff">convert</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #000000">datetime</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff00ff">convert</span><span style="COLOR: #000000"><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">8</span><span style="COLOR: #000000">),</span><span style="COLOR: #ff00ff">dateadd</span><span style="COLOR: #000000">(</span><span style="COLOR: #ff00ff">month</span><span style="COLOR: #000000">,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff00ff">getdate</span><span style="COLOR: #000000">()),</span><span style="FONT-WEIGHT: bold; COLOR: #800000">120</span><span style="COLOR: #000000">)</span><span style="COLOR: #808080">+</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">01</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">120</span><span style="COLOR: #000000">))<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">dateadd</span><span style="COLOR: #000000">(ms,</span><span style="COLOR: #808080">-</span><span style="FONT-WEIGHT: bold; COLOR: #800000">3</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff00ff">DATEADD</span><span style="COLOR: #000000">(mm,</span><span style="COLOR: #ff00ff">DATEDIFF</span><span style="COLOR: #000000">(m,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff00ff">getdate</span><span style="COLOR: #000000">())</span><span style="COLOR: #808080">+</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">))</span></p>
</div>
</center><ccid_nobr></ccid_nobr>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>3.上个月的最后一天 </strong>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<center>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 58.73%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 26px; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">dateadd</span><span style="COLOR: #000000">(ms,</span><span style="COLOR: #808080">-</span><span style="FONT-WEIGHT: bold; COLOR: #800000">3</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff00ff">DATEADD</span><span style="COLOR: #000000">(mm,</span><span style="COLOR: #ff00ff">DATEDIFF</span><span style="COLOR: #000000">(mm,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff00ff">getdate</span><span style="COLOR: #000000">()),</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">))</span></div>
<ccid_nobr></ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>4.本月的第一个星期一i</strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>select DATEADD(wk,DATEDIFF(wk,0, dateadd(dd,6-datepart(
            day,getdate()),getdate())),0)</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>5.本年的第一天 </strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>SELECT DATEADD(yy,DATEDIFF(yy,0,getdate()),0)</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>6.本年的最后一天 </strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>SELECT dateadd(ms,-3,DATEADD(yy,DATEDIFF(yy,0,getdate())+1,0))</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>7.去年的最后一天 </strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>SELECT dateadd(ms,-3,DATEADD(yy,DATEDIFF(yy,0,getdate()),0))</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>8.本季度的第一天 </strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>SELECT DATEADD(qq,DATEDIFF(qq,0,getdate()),0)</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>9.本周的星期一 </strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>SELECT DATEADD(wk,DATEDIFF(wk,0,getdate()),0)</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>10.查询本月的记录 </strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>select * from tableName where DATEPART(mm, theDate)
            =DATEPART(mm, GETDATE()) and DATEPART(yy, theDate)
            = DATEPART(yy, GETDATE())</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>11.查询本周的记录 </strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>select * from tableName where DATEPART(wk, theDate) = DATEPART
            (wk, GETDATE()) and DATEPART(yy, theDate) = DATEPART(yy, GETDATE())</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>12查询本季的记录</strong> 注：其中:GETDATE()是获得系统时间的函数。
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>select * from tableName where DATEPART(qq, theDate) = DATEPART
            (qq, GETDATE()) and DATEPART(yy, theDate) = DATEPART(yy, GETDATE())</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>13.获取当月总天数:</strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>select DATEDIFF(dd,getdate(),DATEADD
            (mm, 1, getdate()))
            select datediff(day,
            dateadd(mm, datediff(mm,'',getdate()), ''),
            dateadd(mm, datediff(mm,'',getdate()), '1900-02-01'))</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center>
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em">
<p style="TEXT-INDENT: 2em"><strong>14.获取当前为星期几</strong>
<p style="TEXT-INDENT: 2em">
<center><ccid_nobr>
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 9pt" bgColor=#e6e6e6>
            <pre><ccid_code>DATENAME(weekday, getdate())</ccid_code></pre>
            </td>
        </tr>
    </tbody>
</table>
</ccid_nobr></center></span>
<img src ="http://www.cnitblog.com/yhf119/aggbug/36177.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-11-12 17:06 <a href="http://www.cnitblog.com/yhf119/archive/2007/11/12/36177.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>防止重复提交数据</title><link>http://www.cnitblog.com/yhf119/archive/2007/10/30/35613.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 30 Oct 2007 08:43:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/10/30/35613.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/35613.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/10/30/35613.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/35613.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/35613.html</trackback:ping><description><![CDATA[使用Cookie或Session来处理。以下以Cookie为例： &nbsp; <br>&nbsp; add.asp &nbsp; <br>&nbsp; &lt;%response.cookies("SubmitFlag")="no"%&gt; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; save.asp &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &lt;% &nbsp; <br>&nbsp; if &nbsp; request.cookies("SubmitFlag")="yes" &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.write &nbsp; "您不能重复提交数据！" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.end &nbsp; <br>&nbsp; end &nbsp; if &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; rs.AddNew &nbsp; <br>&nbsp; &#8230;&#8230; &nbsp; <br>&nbsp; rs.update &nbsp; <br>&nbsp; rs.close &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; response.cookies("SubmitFlag")="yes" &nbsp; <br>&nbsp; %&gt; <br>
<img src ="http://www.cnitblog.com/yhf119/aggbug/35613.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-10-30 16:43 <a href="http://www.cnitblog.com/yhf119/archive/2007/10/30/35613.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>查看 SQL Server 2000 中数据表所占用的磁盘空间</title><link>http://www.cnitblog.com/yhf119/archive/2007/10/30/35606.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 30 Oct 2007 08:10:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/10/30/35606.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/35606.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/10/30/35606.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/35606.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/35606.html</trackback:ping><description><![CDATA[<p>同样的命题在SQL Server 2005中，微软发布了一个报表，可以直接查看，但是这个报表不能用于SQL Server 2000。<br><br>于是我就写了下面这几句话，可以返回同样的结果。<br><br>create table tmp (name varchar(50),rows int,reserved varchar(50),<br>&nbsp;&nbsp;data varchar(50),index_size varchar(50),unused varchar(50))<br>insert into tmp (name,rows,reserved,<br>&nbsp;&nbsp;data,index_size,unused) exec sp_msforeachTable @Command1="sp_spaceused '?'"--sp_spaceused 't_vehicle'<br>select * from tmp order by data desc<br>drop table tmp<br><br>--看单个表, 占用数据的情况 <br>sp_spaceused 'retail11'<br><br>--查看整个数据库所有表占用空间的情况 但发现从sysindexes中取表, 会少一部分数据表(无主键,无索引的表)<br>select object_name(id) tablename,8*reserved/1024 reserved,rtrim(8*dpages/1024)+'Mb' used,8*(reserved-dpages)/1024 unused,8*dpages/1024-rows/1024*minlen/1024 free,<br>rows,* from sysindexes<br>where indid=1<br>order by reserved desc<br><br>--查看整个数据库所有表占用空间的情况 但看起来比较麻烦<br>exec sp_MSforeachtable "exec sp_spaceused '?'"</p>
<img src ="http://www.cnitblog.com/yhf119/aggbug/35606.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-10-30 16:10 <a href="http://www.cnitblog.com/yhf119/archive/2007/10/30/35606.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在MS SQL删除重复行的几种方法 </title><link>http://www.cnitblog.com/yhf119/archive/2007/10/30/35605.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 30 Oct 2007 08:08:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/10/30/35605.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/35605.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/10/30/35605.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/35605.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/35605.html</trackback:ping><description><![CDATA[1。如果有ID字段，就是具有唯一性的字段 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; delect &nbsp; table &nbsp; where &nbsp; id &nbsp; not &nbsp; in &nbsp; ( &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; select &nbsp; max(id) &nbsp; from &nbsp; table &nbsp; group &nbsp; by &nbsp; col1,col2,col3... &nbsp; <br>&nbsp; ) &nbsp; <br>&nbsp; group &nbsp; by &nbsp; 子句后跟的字段就是你用来判断重复的条件，如只有col1，那么只要col1字段内容相同即表示记录相同。 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 2,如果是判断所有字段也可以这样 &nbsp; <br>&nbsp; &nbsp; &nbsp; select &nbsp; * &nbsp; into &nbsp; #aa &nbsp; from &nbsp; table &nbsp; group &nbsp; by &nbsp; id1,id2,.... &nbsp; <br>&nbsp; &nbsp; &nbsp; delete &nbsp; table &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; insert &nbsp; into &nbsp; table &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; select &nbsp; * &nbsp; from &nbsp; #aa &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 3，没有ID的情况 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; select &nbsp; identity(int,1,1) &nbsp; as &nbsp; id,* &nbsp; into &nbsp; #temp &nbsp; from &nbsp; tabel &nbsp; <br>&nbsp; delect &nbsp; # &nbsp; where &nbsp; id &nbsp; not &nbsp; in &nbsp; ( &nbsp; <br>&nbsp; &nbsp; &nbsp; select &nbsp; max(id) &nbsp; from &nbsp; # &nbsp; group &nbsp; by &nbsp; col1,col2,col3...) &nbsp; <br>&nbsp; delect &nbsp; table &nbsp; <br>&nbsp; inset &nbsp; into &nbsp; table(...) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; select &nbsp; ..... &nbsp; from &nbsp; #temp&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>4.&nbsp; col1+','+col2+','...col5 &nbsp; 联合主键 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; select &nbsp; * &nbsp; from &nbsp; &nbsp; table &nbsp; where &nbsp; col1+','+col2+','...col5 &nbsp; in &nbsp; ( &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; select &nbsp; max(col1+','+col2+','...col5) &nbsp; from &nbsp; table &nbsp; &nbsp; <br>&nbsp; where &nbsp; having &nbsp; count(*)&gt;1 &nbsp; <br>&nbsp; group &nbsp; by &nbsp; col1,col2,col3,col4 &nbsp; &nbsp; <br>&nbsp; ) &nbsp; <br>&nbsp; group &nbsp; by &nbsp; 子句后跟的字段就是你用来判断重复的条件，如只有col1，那么只要col1字段内容相同即表示记录相同。&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp; 5&nbsp;&nbsp;&nbsp;<br>&nbsp; select &nbsp; identity(int,1,1) &nbsp; as &nbsp; id,* &nbsp; into &nbsp; #temp &nbsp; from &nbsp; tabel &nbsp; <br>&nbsp; select &nbsp; * &nbsp; from &nbsp; &nbsp; #temp &nbsp; where &nbsp; id &nbsp; in &nbsp; ( &nbsp; <br>&nbsp; &nbsp; &nbsp; select &nbsp; max(id) &nbsp; from &nbsp; #emp &nbsp; where &nbsp; having &nbsp; count(*)&gt;1 &nbsp; group &nbsp; by &nbsp; col1,col2,col3...)&nbsp;&nbsp; <br><br>6.<br>select &nbsp; distinct &nbsp; * &nbsp; into &nbsp; #temp &nbsp; from &nbsp; tablename &nbsp; &nbsp; <br>&nbsp; delete &nbsp; tablename &nbsp; &nbsp; <br>&nbsp; go &nbsp; <br>&nbsp; insert &nbsp; tablename &nbsp; select &nbsp; * &nbsp; from &nbsp; #temp &nbsp; <br>&nbsp; go &nbsp; <br>&nbsp; drop &nbsp; table &nbsp; #temp&nbsp;&nbsp; <br>
<img src ="http://www.cnitblog.com/yhf119/aggbug/35605.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-10-30 16:08 <a href="http://www.cnitblog.com/yhf119/archive/2007/10/30/35605.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>prototype.js开发笔记 (转)</title><link>http://www.cnitblog.com/yhf119/archive/2007/09/29/34173.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Sat, 29 Sep 2007 03:49:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/09/29/34173.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/34173.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/09/29/34173.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/34173.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/34173.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1.&nbsp;Prototype是什么?或许你还没有用过它， prototype.js 是一个由Sam Stephenson写的JavaScript包。这个构思奇妙编写良好的一段兼容标准的一段代码将承担创造胖客户端， 高交互性WEB应用程序的重担。轻松加入Web 2.0特性。如果你最近体验了这个程序包，你很可能会发现文档并不是它的强项之一。像所有在我之前的开发者一样，我只能一头扎进pro...&nbsp;&nbsp;<a href='http://www.cnitblog.com/yhf119/archive/2007/09/29/34173.html'>阅读全文</a><img src ="http://www.cnitblog.com/yhf119/aggbug/34173.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-09-29 11:49 <a href="http://www.cnitblog.com/yhf119/archive/2007/09/29/34173.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>为ASP.NET 2.0网站生成唯一程序集</title><link>http://www.cnitblog.com/yhf119/archive/2007/05/11/26874.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Fri, 11 May 2007 06:36:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/05/11/26874.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/26874.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/05/11/26874.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/26874.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/26874.html</trackback:ping><description><![CDATA[作者：veryhappy(wx.net)
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face="Times New Roman" size=3>&nbsp;</font></o:p></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span><span lang=EN-US><font face="Times New Roman">Visual Studio 2003</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下开发网站的都知道</span><span lang=EN-US><font face="Times New Roman">ASP.NET 1.1</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">网站生成后都是一个唯一命名的程序集（项目名称</span><span lang=EN-US><font face="Times New Roman">.DLL</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">），但是这种情况在</span><span lang=EN-US><font face="Times New Roman">Visual Studio 2005</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的网站开发中不见了。</span><span lang=EN-US><font face="Times New Roman">Visual Studio 2005</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">给我们提供了&#8220;发布网站&#8221;这样方便的功能，不用在像以前一样</span><span lang=EN-US><font face="Times New Roman">COPY</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的部署，但是采用其&#8220;发布网站&#8221;的功能，会在站点的</span><span lang=EN-US><font face="Times New Roman">BIN</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目录中产生</span><span lang=EN-US><font face="Times New Roman">App_Code.compiled</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span><span lang=EN-US><font face="Times New Roman">App_Code.dll</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span><span lang=EN-US><font face="Times New Roman">App_Web_xxxxxx.dll</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，项目名称</span><span lang=EN-US><font face="Times New Roman">.dll</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等等这样的程序集，如果不采用预编译的方式那么产生的文件会更加的多，因为很多都是随机命名也没有什么规律可言；这样会给那些想</span><span lang=EN-US><font face="Times New Roman">COPY</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">更新的人带来不便，因为原来的文件不能被覆盖，需要先删除再</span><span lang=EN-US><font face="Times New Roman">COPY</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">；有很多时候可能就是更新了后台代码，直接生成项目或是</span><span lang=EN-US><font face="Times New Roman">WEB</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的程序集，像以前一样直接覆盖</span><span lang=EN-US><font face="Times New Roman">DLL</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的方式也很简单。</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">也许很多人不会考虑</span><span lang=EN-US><font face="Times New Roman">BIN</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下存放的东西，只要站点能运行就好了，那么这样的人读到这里也就没有必要再看此文章，要知道时间是宝贵的，浪费在自己不关心的事情上很不值得的。</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">上面罗嗦了一堆，下面笔者将介绍采用</span><span lang=EN-US><font face="Times New Roman">Microsoft Web Deployment Projects</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span><span lang=EN-US><font face="Times New Roman">Visual Studio 2005</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中生成唯一程序集的方法。</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">关于</span><span lang=EN-US><font face="Times New Roman">Microsoft Web Deployment Projects</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">工具可以从微软站点获得详尽的资料，我也没什么好说的了微软写的很清楚了，呵呵。</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size=3>下载地址：</font></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><span lang=EN-US><a href="http://msdn.microsoft.com/asp.net/reference/infrastructure/wdp/default.aspx"><font face="Times New Roman" color=#810081 size=3><u>http://msdn.microsoft.com/asp.net/reference/infrastructure/wdp/default.aspx</u></font></a></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size=3>详细使用：</font></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><span lang=EN-US><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/web_deployment_projects.asp"><font face="Times New Roman" color=#810081 size=3><u>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/web_deployment_projects.asp</u></font></a></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><span lang=EN-US><o:p><font face="Times New Roman" size=3>&nbsp;</font></o:p></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">安装后在&#8220;生成&#8221;和</span><span lang=EN-US><font face="Times New Roman">WEB</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">项目的上下文菜单看到&#8220;</span><span lang=EN-US><font face="Times New Roman">Add Web Deployment Project&#8230;</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">&#8221;，好了添加一个</span><span lang=EN-US><font face="Times New Roman">Web Deployment Project</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">项目，起一个名称，这个名称就是将来编译后生成的程序集名称，默认的名称&#8220;当前项目名称</span><span lang=EN-US><font face="Times New Roman">_deploy</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">&#8221;</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/veryhappy/166579/o_a1.JPG"></span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font size=3><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 174pt; HEIGHT: 174.75pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:\DOCUME~1\ADMINI~1.KOS\LOCALS~1\Temp\msohtml1\01\clip_image001.png"></v:imagedata></v:shape></font></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">双击</span><span lang=EN-US><font face="Times New Roman">Web Deployment Project</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的项目出现属性页面</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/veryhappy/166579/o_a2.JPG"></span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><v:shape id=_x0000_i1026 style="WIDTH: 415.5pt; HEIGHT: 258pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:\DOCUME~1\ADMINI~1.KOS\LOCALS~1\Temp\msohtml1\01\clip_image003.png"><font size=3></font></v:imagedata></v:shape></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><font size=3><span lang=EN-US><font face="Times New Roman">Compilation</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</span><span lang=EN-US><font face="Times New Roman">Output Folder</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设置项目输出路径</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><font size=3><span lang=EN-US><font face="Times New Roman">Output Assemblies</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的四大选项：</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/veryhappy/166579/o_a3.JPG"></span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><v:shape id=_x0000_i1027 style="WIDTH: 415.5pt; HEIGHT: 255pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:\DOCUME~1\ADMINI~1.KOS\LOCALS~1\Temp\msohtml1\01\clip_image005.png"><font size=3></font></v:imagedata></v:shape></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo1; tab-stops: list 21.0pt"><span lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><span style="mso-list: Ignore"><font size=3>n</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font size=3><span lang=EN-US><font face="Times New Roman">Merge all outputs to a single assembly</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">－所有输出都编译成一个程序集（参数：程序集名称）</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level2 lfo1; tab-stops: list 42.0pt"><span lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><span style="mso-list: Ignore"><font size=3>n</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font size=3><span lang=EN-US><font face="Times New Roman">Treat as library component (remove the App_Code.compiled file)</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">－</span><span lang=EN-US><font face="Times New Roman">App_Code</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">视为类库（删除</span><span lang=EN-US><font face="Times New Roman">App_Code.compiled</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件）</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo1; tab-stops: list 21.0pt"><span lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><span style="mso-list: Ignore"><font size=3>n</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font size=3><span lang=EN-US><font face="Times New Roman">Merge each individual folder output to its own assembly</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">－</span><span lang=EN-US><font face="Times New Roman">WEB</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">项目中单独的目录会编译到一个程序集中（参数：程序集前缀）</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo1; tab-stops: list 21.0pt"><span lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><span style="mso-list: Ignore"><font size=3>n</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font size=3><span lang=EN-US><font face="Times New Roman">Merge all pages and control outputs to a single assembly</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">－所有页面控件编译到一个程序集中（参数：程序集名称）</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo1; tab-stops: list 21.0pt"><span lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><span style="mso-list: Ignore"><font size=3>n</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font size=3><span lang=EN-US><font face="Times New Roman">Create a separate assembly for each page and control output</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">－为每一个页面和控件创建程序集</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><font size=3><span lang=EN-US><font face="Times New Roman">Signing</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">使用</span><span lang=EN-US><font face="Times New Roman">key</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件建立强命名空间的程序集</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face="Times New Roman" size=3>Deployment</font></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/veryhappy/166579/o_a4.JPG"></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><v:shape id=_x0000_i1028 style="WIDTH: 415.5pt; HEIGHT: 255.75pt" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:\DOCUME~1\ADMINI~1.KOS\LOCALS~1\Temp\msohtml1\01\clip_image007.png"><font face="Times New Roman" size=3></font></v:imagedata></v:shape></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo2; tab-stops: list 21.0pt"><span lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><span style="mso-list: Ignore"><font size=3>n</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font size=3><span lang=EN-US><font face="Times New Roman">Enable Web.config file section replacement</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">－用不同的</span><span lang=EN-US><font face="Times New Roman">config</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件替换</span><span lang=EN-US><font face="Times New Roman">Web.config</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的节点</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo2; tab-stops: list 21.0pt"><span lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><span style="mso-list: Ignore"><font size=3>n</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font size=3><span lang=EN-US><font face="Times New Roman">Create an IIS virtual directory for the output folder</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">－创建</span><span lang=EN-US><font face="Times New Roman">IIS</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">虚拟目录（参数：虚拟目录名称）</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo2; tab-stops: list 21.0pt"><span lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><span style="mso-list: Ignore"><font size=3>n</font><span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font size=3><span lang=EN-US><font face="Times New Roman">Remove the App_Data folder from output location</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">－删除输出目录中的</span><span lang=EN-US><font face="Times New Roman">App_Data</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目录</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">好了通过简单的设置，就可以生成一个看上去非常&#8220;干净利落&#8221;的</span><span lang=EN-US><font face="Times New Roman">bin</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目录，每个程序集都很明显，对部分升级工作很有帮助。</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></span></font></p>
<font size=3><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face="Times New Roman" size=4>2006-6</font></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=4><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实际上在我们的一个实际</span><span lang=EN-US><font face="Times New Roman">ASP.NET 2.0</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的解决方案中来应用这种方式出现了问题，下面我就讲一下我的解决过程希望对大家有所帮助。</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><font size=4><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们的解决方案包括</span><span lang=EN-US><font face="Times New Roman">22</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个项目（主要是类库），其中的一个</span><span lang=EN-US><font face="Times New Roman">WEB</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">项目是负责用户</span><span lang=EN-US><font face="Times New Roman">UI</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的，传统的生成或是发布网站的方式没有任何问题，当使用</span><span lang=EN-US><font face="Times New Roman">Web Deployment Projects</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">工具生成唯一程序集时出现了错误信息&#8220;</span><span lang=EN-US style="COLOR: red"><font face="Times New Roman">Aspnet_merge.exe Exited with Code </font><st1:chmetcnv unitname="&#8221;" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on"><font face="Times New Roman">1</font><span lang=EN-US style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><span lang=EN-US>&#8221;</span></span></st1:chmetcnv><span lang=EN-US style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（</span><font face="Times New Roman">Aspnet_merge.exe </font></span><span style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">退出，错误代码</span><span lang=EN-US style="COLOR: red"><font face="Times New Roman">1</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">），这样的信息根本无法让我们办断到底是哪里出了问题。好，下面依次打开</span><span lang=EN-US><font face="Times New Roman">VS 2005</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的工具－选项－项目和解决方案－生成并运行，设置&#8220;</span><span lang=EN-US><font face="Times New Roman">MSBuild </font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">项目生成输出详细信息&#8221;，选择&#8220;详细&#8221;。再次生成</span><span lang=EN-US><font face="Times New Roman">Web Deployment Projects</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">项目，注意&#8220;输出&#8221;框内的信息现在变得非常丰富了，最后导致无法编译的问题终于出来了&#8220;</span><span lang=EN-US><font face="Times New Roman">An error occurred when merging assemblies: ILMerge.Merge: ERROR!!: Duplicate type &#8216;_Default&#8217; found in assembly 'App_Web_k5hhsnh0'</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">&#8221;，它的意思是说在程序集中发现了相同的类型</span><span lang=EN-US><font face="Times New Roman">_Default</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，经过我检查确实在我们的</span><span lang=EN-US><font face="Times New Roman">WEB</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">项目中存在了两个</span><span lang=EN-US><font face="Times New Roman">_Default</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类（在不同的目录中），这样的问题通过一般的生成完成和发布网站肯定都是检测不出来的，运行也是正常的。</span><span lang=EN-US><font face="Times New Roman">VS 2005</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span><span lang=EN-US><font face="Times New Roman">WEB</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">项目默认的把命名空间给去掉了，可以手动增加一个命名空间，</span><span lang=EN-US><font face="Times New Roman">cs</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码中加入</span><span lang=EN-US><font face="Times New Roman">namespace</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的语句块，另外别忘了在</span><span lang=EN-US><font face="Times New Roman">aspx</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件的</span><span lang=EN-US><font face="Times New Roman">&lt;@page&gt;</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span><span lang=EN-US><font face="Times New Roman">Inherits</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中写入对应的</span><span lang=EN-US><font face="Times New Roman">[namespace].[</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类名</span><span lang=EN-US><font face="Times New Roman">]</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">；经过这样的操作再次编译成一个程序集就没有问题了（备注：这个项目前后一共发现了</span><span lang=EN-US><font face="Times New Roman">5</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对类名称一致的情况，加上命名空间或是改名称就可以解决了）。</span></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font size=4>上面就是结合我的项目实际解决的问题，暂时还没有发现别的错误出来。使用有问题的朋友也多多交流。</font></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">&nbsp;</p>
</span></font>
<img src ="http://www.cnitblog.com/yhf119/aggbug/26874.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-05-11 14:36 <a href="http://www.cnitblog.com/yhf119/archive/2007/05/11/26874.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>aspnet的内部运行机制(运行流程)</title><link>http://www.cnitblog.com/yhf119/archive/2007/05/10/26821.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Thu, 10 May 2007 07:07:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/05/10/26821.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/26821.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/05/10/26821.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/26821.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/26821.html</trackback:ping><description><![CDATA[<p>aspnet的内部运行机制：<br></p>
<p style="FONT-SIZE: 14pt"><font color=#0000ff>remote client Request----&gt;</font><font color=#0000ff>IIS----&gt;aspnet_isapi.dll--&gt;aspnet_wp.exe--&gt;HttpRuntime---&gt;<br></p>
</font>
<p style="FONT-SIZE: 14pt"><font color=#0000ff>HttpModule---&gt;HttpHandler Factory---&gt;HttpHandler---&gt;HttpHandler.ProcessRequest()--&gt;<br></font></p>
<p style="FONT-SIZE: 14pt"><font color=#0000ff>Response client Request</font><br></p>
<img src ="http://www.cnitblog.com/yhf119/aggbug/26821.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-05-10 15:07 <a href="http://www.cnitblog.com/yhf119/archive/2007/05/10/26821.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DataTable操作中的性能问题</title><link>http://www.cnitblog.com/yhf119/archive/2007/05/10/26815.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Thu, 10 May 2007 03:13:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/05/10/26815.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/26815.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/05/10/26815.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/26815.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/26815.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 最近的一项工作是关于性能提升方面的。要做的第一个事情是要把很多同类型的DataTable合并到一起，查了很多关于DataTable的相关函数以后，我决定用Merge函数来合并这些DataTable。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataTable[] srcTables = ... ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach( DataTable src in srcTables )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dest.Merge( src ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 但是测试的结果让我很是失望，性能不是一般的不好。经过调查发现性能的瓶颈在Merge函数这里。后来经过测试，发现如果用下面的代码：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataTable[] srcTables = ... ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach( DataTable src in srcTables )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach( DataRow row in src.Rows)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dest.ImportRow( row ) ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 结果让人惊奇的是，下面的代面的速度是上面的代码速度的100倍！</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 还做了一个事情，就是对DataTable进行filter的时候 ，我的一个同事和我说了以下的代码：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataView dv = dt.DefaultView ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dv.RowFilter = filter ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataTable result = dv.ToTable() ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 上面的代码是能工作的，但是它的性能一点都不好，后来我把上面的代码改成了：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataRow[] rows = dv.Select( filter ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach( DataRow row in rows )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result.ImportRow(row) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 也有数十倍的性能提高。</p>
<img src ="http://www.cnitblog.com/yhf119/aggbug/26815.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-05-10 11:13 <a href="http://www.cnitblog.com/yhf119/archive/2007/05/10/26815.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>提高ASP.Net应用程序性能的十大方法(完整版,带示例带图)</title><link>http://www.cnitblog.com/yhf119/archive/2007/05/08/26728.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 08 May 2007 04:01:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/05/08/26728.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/26728.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/05/08/26728.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/26728.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/26728.html</trackback:ping><description><![CDATA[<div style="LINE-HEIGHT: 180%" align=left>网上搜索的这篇文章都缺少示例和图片，在此补齐，发个完整版。
<p>一、返回多个数据集 </p>
<p>　　检查你的访问数据库的代码，看是否存在着要返回多次的请求。每次往返降低了你的应用程序的每秒能够响应请求的次数。通过在单个数据库请求中返回多个结果集，可以减少与数据库通信的时间，使你的系统具有扩展性，也可以减少数据库服务器响应请求的工作量。 </p>
<p>　　如果你是用动态的SQL语句来返回多个数据集，那我建议你用存储过程来替代动态的SQL语句。是否把业务逻辑写到存储过程中，这个有点争议。但是我认为，把业务逻辑写到存储过程里面可以限制返回结果集的大小，减小网络数据的流量，在逻辑层也不用在过滤数据，这是一个好事情。 </p>
<p>　　用SqlCommand对象的ExecuteReader方法返回一个强类型的业务对象，再调用NextResult方法来移动数据集指针来定位数据集。示例一演示了一个返回多个ArrayList强类型对象的例子。只从数据库中返回你需要的数据可以大大的减小你的服务器所耗用的内存。<br></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;read&nbsp;the&nbsp;first&nbsp;resultset</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">reader&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;command.ExecuteReader();<br><br></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;read&nbsp;the&nbsp;data&nbsp;from&nbsp;that&nbsp;resultset</span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(reader.Read())&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;suppliers.Add(PopulateSupplierFromIDataReader(&nbsp;reader&nbsp;));<br>}<br><br></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;read&nbsp;the&nbsp;next&nbsp;resultset</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">reader.NextResult();<br><br></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;read&nbsp;the&nbsp;data&nbsp;from&nbsp;that&nbsp;second&nbsp;resultset</span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(reader.Read())&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;products.Add(PopulateProductFromIDataReader(&nbsp;reader&nbsp;));<br>}<br><br></span></div>
<p>&nbsp;</p>
<p>二、对数据进行分页 </p>
<p>　　ASP。NET的DataGrid有一个非常有用的功能：分页。如果DataGrid允许分页，在某一时刻它只下载某一页的数据，另外，它有一个数据分页的济览导航栏，它让你可以选择浏览某一页，而且每次只下载一页的数据。 </p>
<p>　　但是它有一个小小的缺点，就是你必须把所有的数据都绑定到DataGrid中。也就是说，你的数据层必须返回所有的数据，然后DataGrid再根据当前页过滤出当前页所需要的数据显示出来。如果有一个一万条记录的结果集要用DataGrid进行分页，假设DataGrid每页只显示25条数据，那就意味着每次请求都有9975条数据都是要丢弃的。每次请求都要返回这么大的数据集，对应用程序的性能影响是非常大的。 </p>
<p>　　一个好的解决方案是写一个分页的存储过程，例子2是一个用于对Northwind数据库orders表的分页存储过程。你只需要传当前页码，每页显示的条数两个参数进来，存储过程会返回相应的结果。 </p>
<p>　　在服务器端，我专门写了一个分页的控件来处理数据的分页，在这里，我用了第一个方法，在一个存储过程里面返回了两个结果集：数据记录总数和要求的结果集。 </p>
<p>　　返回的记录总数取决于要执行查询，例如，一个where条件可以限制返回的结果集的大小。因为在分页界面中必须要根据数据集记录的大小来计算总的页数，所以必须要返回结果集的记录数。例如，如果一共有1000000条记录，如果用where条件就可以过滤成只返回1000条记录，存储过程的分页逻辑应该知道返回那些需要显示的数据。 <br><br></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">--</span><span style="COLOR: #008080">Paging&nbsp;Through&nbsp;the&nbsp;Orders&nbsp;Table</span><span style="COLOR: #008080"><br></span><span style="COLOR: #0000ff">CREATE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">PROCEDURE</span><span style="COLOR: #000000">&nbsp;northwind_OrdersPaged<br>(<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@PageIndex</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">,&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@PageSize</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000"><br>)<br></span><span style="COLOR: #0000ff">AS</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">BEGIN</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">DECLARE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageLowerBound</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">DECLARE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageUpperBound</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">DECLARE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@RowsToReturn</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000"><br><br></span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;First&nbsp;set&nbsp;the&nbsp;rowcount</span><span style="COLOR: #008080"><br></span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@RowsToReturn</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">*</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #008000">@PageIndex</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">ROWCOUNT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@RowsToReturn</span><span style="COLOR: #000000"><br><br></span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;Set&nbsp;the&nbsp;page&nbsp;bounds</span><span style="COLOR: #008080"><br></span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageLowerBound</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">*</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageIndex</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageUpperBound</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageLowerBound</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageSize</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">+</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000"><br><br></span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;Create&nbsp;a&nbsp;temp&nbsp;table&nbsp;to&nbsp;store&nbsp;the&nbsp;select&nbsp;results</span><span style="COLOR: #008080"><br></span><span style="COLOR: #0000ff">CREATE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">TABLE</span><span style="COLOR: #000000">&nbsp;#PageIndex&nbsp;<br>(<br>&nbsp;&nbsp;&nbsp;&nbsp;IndexId&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">IDENTITY</span><span style="COLOR: #000000">&nbsp;(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #808080">NOT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">NULL</span><span style="COLOR: #000000">,<br>&nbsp;&nbsp;&nbsp;&nbsp;OrderID&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000"><br>)<br><br></span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;Insert&nbsp;into&nbsp;the&nbsp;temp&nbsp;table</span><span style="COLOR: #008080"><br></span><span style="COLOR: #0000ff">INSERT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">INTO</span><span style="COLOR: #000000">&nbsp;#PageIndex&nbsp;(OrderID)<br></span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;OrderID<br></span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Orders<br></span><span style="COLOR: #0000ff">ORDER</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">BY</span><span style="COLOR: #000000">&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;OrderID&nbsp;</span><span style="COLOR: #0000ff">DESC</span><span style="COLOR: #000000"><br><br></span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;Return&nbsp;total&nbsp;count</span><span style="COLOR: #008080"><br></span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">COUNT</span><span style="COLOR: #000000">(OrderID)&nbsp;</span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">&nbsp;Orders<br><br></span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">&nbsp;Return&nbsp;paged&nbsp;results</span><span style="COLOR: #008080"><br></span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;O.</span><span style="COLOR: #808080">*</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Orders&nbsp;O,<br>&nbsp;&nbsp;&nbsp;&nbsp;#PageIndex&nbsp;PageIndex<br></span><span style="COLOR: #0000ff">WHERE</span><span style="COLOR: #000000">&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;O.OrderID&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;PageIndex.OrderID&nbsp;</span><span style="COLOR: #808080">AND</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;PageIndex.IndexID&nbsp;</span><span style="COLOR: #808080">&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageLowerBound</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">AND</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;PageIndex.IndexID&nbsp;</span><span style="COLOR: #808080">&lt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@PageUpperBound</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">ORDER</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">BY</span><span style="COLOR: #000000">&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;PageIndex.IndexID<br><br></span><span style="COLOR: #0000ff">END</span><span style="COLOR: #000000"><br><br></span></div>
<p>&nbsp;</p>
<p>三、连接池 </p>
<p>　　用TCP来连接你的应用程序与数据库是一件昂贵的事情（很费时的事情），微软的开发者可以通过用连接池来反复的使用数据库的连接。比起每次请求都用TCP来连一次数据库，连接池只有在不存在有效的连接时才新建一个TCP连接。当关闭一个连接的时候，它会被放到池中，它仍然会保持与数据库的连接，这样就可以减少与数据库的TCP连接次数。 </p>
<p>　　当然，你要注意那些忘记关的连接，你应在每次用完连接后马上关闭它。我要强调的是：无论什么人说.net framework中的GC(垃圾收集器)总会在你用完连接对象后调用连接对象的Close或者Dispose方法显式的关闭你的连接。不要期望CLR会在你想象的时间内关掉连接，虽然CLR最终都要销毁对象和关闭边接，但是我们并不能确定它到底会在什么时候做这些事情。 </p>
<p>　　要用连接池优化，有两条规则，第一，打开连接，处理数据，然后关闭连接。如果你必须在每次请求中多次打开或关闭连接，这好过一直打开一个边接，然后把它传到各个方法中。第二，用相同的连接字符串（或者用相同的用户标识，当你用集成认证的时候）。如果你没有用相同的连接字符串，如你用基于登录用户的连接字符串，这将不能利用连接池的优化功能。如果你用的是集成的论证，因为用户很多，所以你也不能充分利用连接池的优化功能。.NET CLR提供了一个数据性能计数器，它在我们需要跟踪程序性能特性的时候非常有用，当然也包括连接池的跟踪了。 </p>
<p>　　无论你的应用程序什么时候要连在另一台机子的资源，如数据库，你都应该重点优化你连资源所花的时间，接收和发送数据的时间，以及往返回之间的次数。优化你的应用程序中的每一个处理点（process hop），它是提高你的应用的性能的出发点。 </p>
<p>　　应用程序层包含与数据层连接，传送数据到相应的类的实例以及业务处理的逻辑。例如，在Community Server中，要组装一个Forums或者Threads集合，然后应用业务逻辑，如授权，更重要的，这里要完成缓存逻辑。 </p>
<p>四、ASP.NET缓存API </p>
<p>　　在写应用程序之前,你要做的第一件事是让应用程序最大化的利用ASP.NET的缓存功能。 </p>
<p>　　如果你的组件是要在Asp.net应用程序中运行，你只要把System.Web.dll引用到你的项目中就可以了。然后用HttpRuntime.Cache属性就可访问Cache了（也可以通过Page.Cache或HttpContext.Cache访问）。 </p>
<p>　　有以下几条缓存数据的规则。第一，数据可能会被频繁的被使用，这种数据可以缓存。第二，数据的访问频率非常高，或者一个数据的访问频率不高，但是它的生存周期很长，这样的数据最好也缓存起来。第三是一个常常被忽略的问题，有时候我们缓存了太多数据，通常在一台X86的机子上，如果你要缓存的数据超过800M的话，就会出现内存溢出的错误。所以说缓存是有限的。换名话说，你应该估计缓存集的大小，把缓存集的大小限制在10以内，否则它可能会出问题。在Asp.net中，如果缓存过大的话也会报内存溢出错误，特别是如果缓存大的DataSet对象的时候。 </p>
<p>　　这里有几个你必须了解的重要的缓存机制。首先是缓存实现了&#8220;最近使用&#8221;原则（ a least-recently-used algorithm），当缓存少的时候，它会自动的强制清除那些无用的缓存。其次 &#8220;条件依赖&#8221;强制清除原则（expiration dependencies），条件可以是时间，关键字和文件。以时间作为条件是最常用的。在asp.net2.0中增加一更强的条件，就是数据库条件。当数据库中的数据发生变化时，就会强制清除缓存。要更深入的了解数据库条件依赖请看Dino Esposito 在MSDN杂志2004年七月刊的Cutting Edge专栏文章。Asp.net的缓存架构如下图所示： <br>　　 <img height=236 alt="Figure 3 ASP.NET Cache" src="http://msdn.microsoft.com/msdnmag/issues/05/01/ASPNETPerformance/fig03.gif" width=161 border=0><br>五、预请求缓存 </p>
<p>　　在前面，我提到过即使我们只对某些地方作了一个小小的性能改进也可以获得大的性能提升，我非常喜欢用预请求缓存来提升程序的性能。 </p>
<p>　　虽然Cache API设计成用来保存某段时间的数据，而预请求缓存只是保存某个时期的某个请求的内容。如果某个请求的访问频率高，而且这个请求只需要提取，应用，修改或者更新数据一次。那么就可以预缓存该请求。我们举个例子来说明。 </p>
<p>　　在CS的论坛应用程序中，每一个页面的服务器控件都要求得到用于决定它的皮肤（skin）的自定义的数据，以决定用哪个样式表及其它的一些个性化的东西。这里面的某些数据可能要长时间的保存，有些时间则不然，如控件的skin数据，它只需要应用一次，而后就可以一直使用。 </p>
<p>　　要实现预请求缓存，用Asp.net 的HttpContext类，HttpContext类的实例在每一个请求中创建，在请求期间的任何地方都可以通过HttpContext.Current属性访问。HttpContext类有一个Items集合属性，在请求期间所有的对象和数据都被添加到这个集合中缓存起来。和你用Cache缓存访问频率高数据一样，你可以用HttpContext.Items缓存那些每个请求都要用到的基础数据。它背后的逻辑很简单：我们向HttpContext.Items中添加一个数据，然后再从它里面读出数据。</p>
<p>六、后台处理 </p>
<p>　　通过上面的方法你的应用程序应该运行得很快了，是不是？但是在某些时候，程序中的一次请求中可能要执行一个非常耗时的任务。如发送邮件或者是检查提交的数据的正确性等。 </p>
<p>　　当我们把asp.net Forums 1.0集成在CS中的时侯，发现提交一个新的帖子的时候会非常的慢。每次新增一个帖子的时侯，应用程序首先要检查这个帖子是不是重复提的，然后用&#8220;badword&#8221;过滤器来过滤，检查图片附加码，作帖子的索引，把它添加到合适的队列中，验证它的附件，最后，发邮件到它的订阅者邮件箱中。显然，这个工作量很大。 </p>
<p>　　结果是它把大量的时间都花在做索引和发送邮件中了。做帖子的索引是一项很耗时的操作，而发邮件给订阅都需要连接到SMTP服务，然后给每一个订阅者都发一封邮件，随着订阅用户的增加，发送邮件的时间会更长。 </p>
<p>　　索引和发邮件并不需要在每次请求时触发，理想状态下，我们想要批量的处理这些操作，每次只发25封邮件或者每隔5分钟把所有的要发的新邮件发一次。我们决定使用与数据库原型缓存一样的代码，但是失败了，所以又不得不回到VS.NET 2005。 </p>
<p>　　我们在System.Threading命名空间下找到了Timer类，这个类非常有用，但却很少有人知道，Web开发人员则更少有人知道了。一旦他建了该类的实例，每隔一个指定的时间，Timer类就会从线程池中的一个线程中调用指定的回调函数。这意味着你的asp.net应用程序可以在没有请求的时候也可以运行。这就是后以处理的解决方案。你就可以让做索引和发邮件工作在后台运行，而不是在每次请求的时候必须执行。 </p>
<p>　　后台运行的技术有两个问题，第一是，当你的应用程序域卸载后，Timer类实例就会停止运行了。也就是不会调用回调方法了。另外，因为CLR的每个进程中都有许多的线程在运行，你将很难让Timer获得一个线程来执行它，或者能执行它，但会延时。Asp.net层要尽量少的使用这种技术，以减少进程中线程的数量，或者只让请求用一小部分的线程。当然如果你有大量的异步工作的话，那就只能用它了。 </p>
<p>　　你可以从<a href="http://www.rob-howard.net/" target=_blank><u><font color=#0000ff>http://www.rob-howard.net/</font></u></a>中下载示例程序，请下载Blackbelt TechEd 2004的示例程序。 </p>
<p>七、页面输出缓存和代理服务 </p>
<p>　　Asp.net是你的界面层（或者说应该是），它包含页面，用户控件，服务器控件（HttpHandlers 和HttpModules）以及它们生成的内容。如果你有一个Asp.net页面用来输出html，xml,imgae或者是其它的数据，对每一个请求你都用代码来生成相同的输出内容，你就很有必要考虑用页面输出缓存了。 </p>
<p>　　你只要简单的把下面的这一行代码复制到你的页面中就可以实现了：&lt;%@ PageOutputCache VaryByParams=&#8221;none&#8221; Duration=&#8221;60&#8221; %&gt; 你就可以有效的利用第一次请求里生成的页面输出缓存内容，60秒后重新生成一道页面内容。这种技术其实也是运用一些低层的Cache API来实现。用页面输出缓存有几个参数可以配置，如上面所说的VaryByParams参数，该参数表示什么时候触发重输出的条件，也可以指定在Http Get或Http Post 请求模式下缓存输出。例如当我们设置该参数为VaryByParams=&#8221;Report&#8221;的时候，default.aspx?Report=1或者default.aspx?Report=2请求的输出都会被缓存起来。参数的值可以是多个用分号隔开参数。 </p>
<p>　　许多人都没有意识到当用页面输出缓存的时候，asp.net也会生成HTTP头集（HTTP Header）保存在下游的缓存服务器中，这些信息可以用于Microsoft Internet安全性中以及加速服务器的响应速度。当HTTP缓存的头被重置时，请求的内容会被缓在网络资源中，当客户端再次请求该内容时，就不会再从源服务器上获得内容了，而直接从缓存中获得内容。 </p>
<p>　　虽然用页面输出缓存不提高你的应用程序性能，但是它能减少了从的服务器中加载已缓存页面内容的次数。当然，这仅限于缓存匿名用户可以访问的页面。因为一旦页面被缓存后，就不能再执行授权操作了。 </p>
<p>八、 用IIS6.0的Kernel Caching </p>
<p>　　如果你的应用程序没用运行在IIS6.0(windows server 2003)中，那么你就失去了一些很好的提高应用程序性能的方法。在第七个方法中，我讲了用页面输出缓存提高应用程序的性能的方法。在IIS5.0中，当一个请求到来到IIS后，IIS会把它转给asp.net，当应用了页面输出缓存时，ASP.NET中的HttpHandler会接到该请求，HttpHandler从缓存中把内容取出来并返回。 </p>
<p>　　如果你用的是IIS6.0，它有一个非常好的功能就是Kernel Caching，而且你不必修改asp.net程序中任何代码。当asp.net接到一个已缓存的请求，IIS的Kernel Cache会从缓存中得到它的一份拷贝。当从网络中传来一个请求的时，Kernel层会得到该请求，如果该请求被缓存起来了，就直接把缓存的数据返回，这样就完工了。这就意味着当你用IIS的Kernel Caching来缓存页面输出时，你将获得不可置信的性能提升。在开发VS.NET 2005的 asp.net时有一点，我是专门负asp.net性能的程序经理，我的程序员用了这个方法，我看了所有日报表数据，发现用kernel model caching的结果总是最快的。它们的一个共同的特征就是网络的请求和响应量很大,但IIS只占用了5%的CPU资源。这是令人惊奇的。有许多让你使用用IIS6.0的理由，但kernel cashing是最好的一个。 </p>
<p>九、 用Gzip压缩数据 </p>
<p>　　除非你的CPU占用率太高了，才有必要用提升服务器性能的技巧。用gzip压缩数据的方法可以减少你发送到服务端的数据量，也可以提高页面的运行速度，同时也减少了网络的流量。怎么样更好的压缩数据取决于你要发送的数据，还有就是客户端的浏览器支不支持（IIS把用gzip压缩后的数据发送到客户端，客户端要支持gzip才能解析，IE6.0和Firefox都支持）。这样你的服务器每秒能多响应一些请求，同样，你也减少了发送响应的数据量，也就能多发送一些请求了。 </p>
<p>　　好消息，gzip压缩已经被集成在IIS6.0中了，它比IIS5.0中gzip更好。不幸的是，在IIS6.0中启用gzip压缩，你不能在IIS6.0的属性对话中设置。IIS开发团队把gzip压缩功能开发出来了，但他们却忘了在管理员窗口中让管理员能很方便的启用它。要启用gzip压缩，你只能深入IIS6.0的xml配置文件中修改它的配置。 </p>
<p>　　除了阅读本文以外，只好再看看Brad Wilson写的 IIS6 压缩一文：<a href="http://www.dotnetdevs.com/articles/IIS6compression.aspx" target=_blank><u><font color=#0000ff>http://www.dotnetdevs.com/articles/IIS6compression.aspx</font></u></a>；另外还有一篇介绍aspx压缩基础知识的文章，Enable ASPX Compression in IIS。但是要注意，在IIS6中动态压缩和kernel cashing是互斥的。 </p>
<p>十、 服务器控件的ViewState </p>
<p>　　ViewState是asp.net中的一个特性，它用于把生成页面要用的一状态值保存在一个隐藏域中。当页面被回传到服务器时，服务器要解析，校验和应用ViewState中的数据以还原页面的控件树。ViewState是一个非常有用的特性，它能持久化客户端的状态而不用cookie或者服务器的内存。大部分的服务器控件都是用ViewState来持久化那些在页面中与用户交互的元素的状态值。例如，用以保存用于分页的当前页的页码。 </p>
<p>　　用ViewState会带来一些负面的影响。首先，它加大的服务器的响应和请求的时间。其次，每次回传时都增加了序列化和反序列化数据的时间。最后，它还消耗了服务器更多的内存。 </p>
<p>　　许多的服务器控件很趋于使用ViewState，如众所周知的DataGrid，而有时候是没有必须使用的。默认情况下是允许使用ViewState的，如果你不想使用ViewState的话，你可以在控件或页面级别把关闭它。在控件中，你只要把EnableViewState属性设为False就可以了；你也可以在页面中设置，使它的范围扩展到整个页面中： &lt;%@ Page EnableViewState=&#8221;false&#8221; %&gt; 如果页面无需回传或者每次请求页面只是呈现控件。你就应该在页面级别中把ViewState关掉。</p>
<br></div>
<div style="LINE-HEIGHT: 180%" align=left>原文:http://msdn.microsoft.com/msdnmag/issues/05/01/ASPNETPerformance/default.aspx (英文)</div>
<img src ="http://www.cnitblog.com/yhf119/aggbug/26728.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-05-08 12:01 <a href="http://www.cnitblog.com/yhf119/archive/2007/05/08/26728.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>加大SQL Server最大内存设置，可以显著提高网站访问速度！</title><link>http://www.cnitblog.com/yhf119/archive/2007/03/23/24489.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Fri, 23 Mar 2007 06:09:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/03/23/24489.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/24489.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/03/23/24489.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/24489.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/24489.html</trackback:ping><description><![CDATA[
		<p>如题，如果发现网站访问速度突然变慢。可以试着加大Sql server最大内存的值，可以显著提高访问速度。<br /><br />当然，最好的解决方法还是优化网站程序。<br /><br />PS：大网站要记得禁止IIS写入网站日志，禁止后重启IIS。</p>
<img src ="http://www.cnitblog.com/yhf119/aggbug/24489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-03-23 14:09 <a href="http://www.cnitblog.com/yhf119/archive/2007/03/23/24489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Asp.net(c#)实现多线程断点续传</title><link>http://www.cnitblog.com/yhf119/archive/2007/03/20/24359.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 20 Mar 2007 09:44:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/03/20/24359.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/24359.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/03/20/24359.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/24359.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/24359.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span> <span style="COLOR: #000000">  System.IO.Stream iStream </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">; <br /></span><span style="COLOR: #008080"> 2</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080"> 3</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Buffer to read 10K bytes in chunk: </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080"> 4</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">byte</span><span style="COLOR: #000000">[] buffer </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Byte[</span><span style="COLOR: #000000">10240</span><span style="COLOR: #000000">]; <br /></span><span style="COLOR: #008080"> 5</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080"> 6</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Length of the file: </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080"> 7</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> length; <br /></span><span style="COLOR: #008080"> 8</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080"> 9</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Total bytes to read: </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">10</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> dataToRead; <br /></span><span style="COLOR: #008080">11</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080">12</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Identify the file to download including its path. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">13</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> filepath </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">@"</span><span style="COLOR: #000000">E:\software\SQL Server 2000 Personal Edition.ISO</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">; <br /></span><span style="COLOR: #008080">14</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080">15</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Identify the file name. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">16</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> filename </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> System.IO.Path.GetFileName(filepath); <br /></span><span style="COLOR: #008080">17</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080">18</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #008080">19</span> <span style="COLOR: #000000">   { <br /></span><span style="COLOR: #008080">20</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Open the file. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">21</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   iStream </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> System.IO.FileStream(filepath, System.IO.FileMode.Open, <br /></span><span style="COLOR: #008080">22</span> <span style="COLOR: #000000">   System.IO.FileAccess.Read,System.IO.FileShare.Read); <br /></span><span style="COLOR: #008080">23</span> <span style="COLOR: #000000">   Response.Clear(); <br /></span><span style="COLOR: #008080">24</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080">25</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Total bytes to read: </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">26</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   dataToRead </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> iStream.Length; <br /></span><span style="COLOR: #008080">27</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080">28</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> p </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; <br /></span><span style="COLOR: #008080">29</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(Request.Headers[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Range</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) <br /></span><span style="COLOR: #008080">30</span> <span style="COLOR: #000000">   { <br /></span><span style="COLOR: #008080">31</span> <span style="COLOR: #000000">   Response.StatusCode </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">206</span><span style="COLOR: #000000">; <br /></span><span style="COLOR: #008080">32</span> <span style="COLOR: #000000">   p </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000">.Parse( Request.Headers[</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Range</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">].Replace(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">bytes=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">).Replace(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">)); <br /></span><span style="COLOR: #008080">33</span> <span style="COLOR: #000000">   } <br /></span><span style="COLOR: #008080">34</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(p </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">) <br /></span><span style="COLOR: #008080">35</span> <span style="COLOR: #000000">   { <br /></span><span style="COLOR: #008080">36</span> <span style="COLOR: #000000">   Response.AddHeader(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-Range</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">bytes </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> p.ToString() </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> ((</span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000">)(dataToRead </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)).ToString() </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> dataToRead.ToString()); <br /></span><span style="COLOR: #008080">37</span> <span style="COLOR: #000000">   } <br /></span><span style="COLOR: #008080">38</span> <span style="COLOR: #000000">   Response.AddHeader(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-Length</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,((</span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000">)(dataToRead</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">p)).ToString()); <br /></span><span style="COLOR: #008080">39</span> <span style="COLOR: #000000">   Response.ContentType </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">application/octet-stream</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">; <br /></span><span style="COLOR: #008080">40</span> <span style="COLOR: #000000">   Response.AddHeader(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Content-Disposition</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">attachment; filename=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> System.Web.HttpUtility.UrlEncode(Request.ContentEncoding.GetBytes(filename))); <br /></span><span style="COLOR: #008080">41</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080">42</span> <span style="COLOR: #000000">   iStream.Position </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> p; <br /></span><span style="COLOR: #008080">43</span> <span style="COLOR: #000000">   dataToRead </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> dataToRead </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> p; <br /></span><span style="COLOR: #008080">44</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Read the bytes. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">45</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> (dataToRead </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">) <br /></span><span style="COLOR: #008080">46</span> <span style="COLOR: #000000">   { <br /></span><span style="COLOR: #008080">47</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Verify that the client is connected. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">48</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (Response.IsClientConnected) <br /></span><span style="COLOR: #008080">49</span> <span style="COLOR: #000000">   { <br /></span><span style="COLOR: #008080">50</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Read the data in buffer. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">51</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   length </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> iStream.Read(buffer, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">10240</span><span style="COLOR: #000000">); <br /></span><span style="COLOR: #008080">52</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080">53</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Write the data to the current output stream. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">54</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   Response.OutputStream.Write(buffer, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, length); <br /></span><span style="COLOR: #008080">55</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080">56</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Flush the data to the HTML output. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">57</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   Response.Flush(); <br /></span><span style="COLOR: #008080">58</span> <span style="COLOR: #000000">   <br /></span><span style="COLOR: #008080">59</span> <span style="COLOR: #000000">   buffer</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Byte[</span><span style="COLOR: #000000">10240</span><span style="COLOR: #000000">]; <br /></span><span style="COLOR: #008080">60</span> <span style="COLOR: #000000">   dataToRead </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> dataToRead </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> length; <br /></span><span style="COLOR: #008080">61</span> <span style="COLOR: #000000">   } <br /></span><span style="COLOR: #008080">62</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #008080">63</span> <span style="COLOR: #000000">   { <br /></span><span style="COLOR: #008080">64</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">prevent infinite loop if user disconnects </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">65</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   dataToRead </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; <br /></span><span style="COLOR: #008080">66</span> <span style="COLOR: #000000">   } <br /></span><span style="COLOR: #008080">67</span> <span style="COLOR: #000000">   } <br /></span><span style="COLOR: #008080">68</span> <span style="COLOR: #000000">   } <br /></span><span style="COLOR: #008080">69</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (Exception ex) <br /></span><span style="COLOR: #008080">70</span> <span style="COLOR: #000000">   { <br /></span><span style="COLOR: #008080">71</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Trap the error, if any. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">72</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   Response.Write(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Error : </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> ex.Message); <br /></span><span style="COLOR: #008080">73</span> <span style="COLOR: #000000">   } <br /></span><span style="COLOR: #008080">74</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">finally</span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #008080">75</span> <span style="COLOR: #000000">   { <br /></span><span style="COLOR: #008080">76</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (iStream </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) <br /></span><span style="COLOR: #008080">77</span> <span style="COLOR: #000000">   { <br /></span><span style="COLOR: #008080">78</span> <span style="COLOR: #000000">   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">Close the file. </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">79</span> <span style="COLOR: #008000"></span><span style="COLOR: #000000">   iStream.Close(); <br /></span><span style="COLOR: #008080">80</span> <span style="COLOR: #000000">   } <br /></span><span style="COLOR: #008080">81</span> <span style="COLOR: #000000">   Response.End(); <br /></span><span style="COLOR: #008080">82</span> <span style="COLOR: #000000">   } <br /></span><span style="COLOR: #008080">83</span> <span style="COLOR: #000000"></span></div>
<img src ="http://www.cnitblog.com/yhf119/aggbug/24359.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-03-20 17:44 <a href="http://www.cnitblog.com/yhf119/archive/2007/03/20/24359.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在 ASP 中连接到 SQL Server 使用的身份验证方法</title><link>http://www.cnitblog.com/yhf119/archive/2007/03/17/24175.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Sat, 17 Mar 2007 07:19:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/03/17/24175.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/24175.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/03/17/24175.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/24175.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/24175.html</trackback:ping><description><![CDATA[<h2 class=subTitle id=tocHeadRef>概要</h2>
<script type="text/javascript"><![CDATA[oadTOCNode(1, 'summary');]]&gt;</script>
<div class=sbody>SQL Server 身份验证（标准安全性）和 Windows NT 身份验证（集成安全性）都是用来从 Active Server Page (ASP) 访问 SQL Server 数据库的 SQL Server 身份验证方法。<br><br><strong>注意</strong>：本文不适用于 Microsoft Windows 2000 Active Directory 域。本文所讨论的 Microsoft Windows NT 身份验证模式仅适用于 Windows NT 域。
<p class=topOfPage><a href="http://support.microsoft.com/kb/247931/zh-cn?spid=2852&amp;sid=global#top"><img alt="" src="http://support.microsoft.com/library/images/support/en-us/uparrow.gif">回到顶端</a></p>
</div>
<h2 class=subTitle id=tocHeadRef>更多信息</h2>
<script type="text/javascript"><![CDATA[oadTOCNode(1, 'moreinformation');]]&gt;</script>
<div class=sbody>
<h4 id=tocHeadRef>SQL Server 身份验证</h4>
<script type="text/javascript"><![CDATA[oadTOCNode(3, 'moreinformation');]]&gt;</script>SQL Server 身份验证依赖于 SQL Server 计算机维护的内部用户列表。该列表不包含 Windows NT 用户并且是特定于 SQL Server 计算机的。可以使用 SQL Server 企业管理器创建和配置用户。要使用此身份验证方法，请执行下列步骤：
<table class="list ul">
    <tbody>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>如果通过开放式数据库连接 (ODBC) 进行连接，在 ODBC 管理器中配置数据源时，请选择 SQL Server 身份验证。</td>
        </tr>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>在 ActiveX 数据对象 (ADO) 连接字符串中，使用 ODBC 时应包括参数&#8220;UID&#8221;和&#8220;PWD&#8221;；使用 SQLOLEDB 提供程序时应包括参数&#8220;User ID&#8221;和&#8220;Password&#8221;。</td>
        </tr>
    </tbody>
</table>
<h4 id=tocHeadRef>Windows NT 身份验证</h4>
<script type="text/javascript"><![CDATA[oadTOCNode(3, 'moreinformation');]]&gt;</script>运行 SQL Server 的计算机允许通过 Windows NT 帐户访问其数据。要启用 Windows NT 身份验证，必须通过 Internet Information Server (IIS) 计算机为 Web 应用程序启用基本身份验证。为此，请执行下列步骤：
<table class="list ol">
    <tbody>
        <tr>
            <td class=number>1.</td>
            <td class=text>启动 Internet 服务管理器。</td>
        </tr>
        <tr>
            <td class=number>2.</td>
            <td class=text>浏览到网站，右键单击该网站，然后单击<strong>属性</strong>。</td>
        </tr>
        <tr>
            <td class=number>3.</td>
            <td class=text>单击<strong>目录安全性</strong>选项卡，单击&#8220;匿名访问和身份验证控制&#8221;下的<strong>编辑</strong>，然后选择<strong>基本身份验证</strong>（密码以明文形式发送）选项。</td>
        </tr>
    </tbody>
</table>
要配置 IIS 以实现 Windows NT 身份验证，您不能使用 Windows NT 质询/响应 (NTLM) 身份验证。必须使用下面两种 IIS 身份验证方法中的一种：
<table class="list ul">
    <tbody>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>仅为 Web 应用程序启用基本身份验证。</td>
        </tr>
        <tr>
            <td class=bullet>&#8226;</td>
            <td class=text>如果允许用户进行匿名访问，请验证以下内容：
            <table class="list ul">
                <tbody>
                    <tr>
                        <td class=bullet>&#8226;</td>
                        <td class=text>如果在 IIS 中将用户配置为匿名用户，则还必须在运行 SQL Server 的计算机上的 Windows NT 帐户中配置它们。</td>
                    </tr>
                    <tr>
                        <td class=bullet>&#8226;</td>
                        <td class=text>如果 SQL Server 和 IIS 不在同一台计算机上，则应将用户创建为可访问这两台计算机的域帐户，或者使用同一密码在 SQL Server 计算机和 IIS 计算机上本地创建用户。如果在这两台计算机上本地创建用户，则必须在 SQL Server 计算机上授予该用户本地登录的权限。如果用户是一个域帐户，则必须在 SQL Server 计算机上授予该用户&#8220;从网络访问此计算机&#8221;的权限。</td>
                    </tr>
                    <tr>
                        <td class=bullet>&#8226;</td>
                        <td class=text>如果 SQL Server 和 IIS 不在同一台计算机上，则应启动 Internet 服务管理器（位于 Web 应用程序的&#8220;目录安全性&#8221;属性页上），打开<strong>匿名用户帐户</strong>对话框，禁用<strong>启用自动密码同步</strong>选项，然后手动输入帐户密码。</td>
                    </tr>
                    <tr>
                        <td class=bullet>&#8226;</td>
                        <td class=text>IIS 计算机需要使用该用户密码生成一个在另一台服务器上仍然有效的安全令牌。启用<strong>启用自动密码同步</strong>选项时，则只能为本地计算机生成令牌。</td>
                    </tr>
                    <tr>
                        <td class=bullet>&#8226;</td>
                        <td class=text>如果 IIS 和 SQL Server 位于同一台计算机上，则连接字符串和 ODBC 配置数据源（如果适用）中 SQL Server 数据源的名称将是本地名称。</td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
此外，还应执行下列步骤以便在 ASP 中使用 Windows NT 身份验证连接到 SQL Server 计算机：
<table class="list ol">
    <tbody>
        <tr>
            <td class=number>1.</td>
            <td class=text>如果通过 ODBC 进行连接，在 ODBC 管理器中配置数据源时，请选择 Windows NT 身份验证。</td>
        </tr>
        <tr>
            <td class=number>2.</td>
            <td class=text>在 ActiveX 数据对象 (ADO) 连接字符串中，使用 ODBC 时应省略参数&#8220;UID&#8221;和&#8220;PWD&#8221;，使用 SQLOLEDB 提供程序时应省略参数&#8220;User ID&#8221;和&#8220;Password&#8221;。</td>
        </tr>
        <tr>
            <td class=number>3.</td>
            <td class=text>如果使用用于 SQL Server 的 OLEDB 提供程序 (Provider=SQLOLEDB) 进行连接，则连接字符串必须包括&#8220;Integrated Security=SSPI&#8221;。</td>
        </tr>
        <tr>
            <td class=number>4.</td>
            <td class=text>在 SQL Server 企业管理器中，将需要通过集成安全性访问的所有 Windows NT 帐户和组添加到登录中，并将它们定义为使用 Windows NT 身份验证。为了简化管理，Microsoft 建议您添加 Windows NT 组而不是单个帐户。在定义帐户时，将权限配置到所有必需的数据库、表和存储过程中。</td>
        </tr>
    </tbody>
</table>
下列错误消息表明用于 Windows NT 身份验证的 SQL Server 配置存在问题：
<div class=errormsg>Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)<br>[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '\'.<br><br>Microsoft OLE DB Provider for ODBC Drivers error '80040e4d'<br>[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. <br><br><br>来源：<a href="http://support.microsoft.com/kb/247931/zh-cn?spid=2852&amp;sid=global">http://support.microsoft.com/kb/247931/zh-cn?spid=2852&amp;sid=global</a></div>
</div>
<img src ="http://www.cnitblog.com/yhf119/aggbug/24175.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-03-17 15:19 <a href="http://www.cnitblog.com/yhf119/archive/2007/03/17/24175.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>常用的数据库连接字符串</title><link>http://www.cnitblog.com/yhf119/archive/2007/03/14/24029.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Wed, 14 Mar 2007 06:23:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/03/14/24029.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/24029.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/03/14/24029.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/24029.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/24029.html</trackback:ping><description><![CDATA[
		<span style="COLOR: #000000">asp.net:<br /><br />Data Source=.;Integrated Security=SSPI;Initial Catalog=MaxpcNew<br /><br />asp:<br /><br />Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=pubs;Data Source=.</span>
		<span style="COLOR: #000000">
				<br />
		</span>
		<span style="COLOR: #000000">
				<br />
				<br />
		</span>
<img src ="http://www.cnitblog.com/yhf119/aggbug/24029.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-03-14 14:23 <a href="http://www.cnitblog.com/yhf119/archive/2007/03/14/24029.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Javascript 获取链接(url)参数的方法 </title><link>http://www.cnitblog.com/yhf119/archive/2007/03/09/23781.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Fri, 09 Mar 2007 03:07:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/03/09/23781.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/23781.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/03/09/23781.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/23781.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/23781.html</trackback:ping><description><![CDATA[用正则匹配的方式：<br /><span class="code_title">Javascript:</span><br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span> <span style="COLOR: #0000ff">function</span><span style="COLOR: #000000"> getQueryString(name) <br /></span><span style="COLOR: #008080">2</span> <span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">3</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000"> reg </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> RegExp(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">(^|\\?|&amp;)</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> name </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">=([^&amp;]*)(\\s|&amp;|$)</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">i</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">4</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (reg.test(location.href)) </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> unescape(RegExp.$</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">.replace(</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">\</span><span style="COLOR: #000000">+/</span><span style="COLOR: #000000">g, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)); <br /></span><span style="COLOR: #008080">5</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">; <br /></span><span style="COLOR: #008080">6</span> <span style="COLOR: #000000">}</span></div><br /><br />分解链接的方式：<br /><span class="code_title">Javascript:</span><div class="code_container"><pre class="javascript"><ol><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1">&lt;script type=<span class="st0">"text/javascript"</span>&gt; </div></li><li class="li1"><div class="de1">&lt;!-- </div></li><li class="li1"><div class="de1"><span class="kw2">function</span> getQueryString<span class="br0">(</span><span class="kw3">name</span><span class="br0">)</span></div></li><li class="li2"><div class="de2"><span class="br0">{</span></div></li><li class="li1"><div class="de1"><span class="co1">// 如果链接没有参数，或者链接中不存在我们要获取的参数，直接返回空 </span></div></li><li class="li1"><div class="de1"><span class="kw1">if</span><span class="br0">(</span>location.<span class="me1">href</span>.<span class="me1">indexOf</span><span class="br0">(</span><span class="st0">"?"</span><span class="br0">)</span>==<span class="nu0">-1</span> || location.<span class="me1">href</span>.<span class="me1">indexOf</span><span class="br0">(</span><span class="kw3">name</span>+<span class="st0">'='</span><span class="br0">)</span>==<span class="nu0">-1</span><span class="br0">)</span></div></li><li class="li1"><div class="de1"><span class="br0">{</span></div></li><li class="li1"><div class="de1"><span class="kw1">return</span><span class="st0">''</span>; </div></li><li class="li2"><div class="de2"><span class="br0">}</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="co1">// 获取链接中参数部分 </span></div></li><li class="li1"><div class="de1"><span class="kw2">var</span> queryString = location.<span class="me1">href</span>.<span class="me1">substring</span><span class="br0">(</span>location.<span class="me1">href</span>.<span class="me1">indexOf</span><span class="br0">(</span><span class="st0">"?"</span><span class="br0">)</span><span class="nu0">+1</span><span class="br0">)</span>; </div></li><li class="li1"><div class="de1"> </div></li><li class="li2"><div class="de2"><span class="co1">// 分离参数对 ?key=value&amp;key2=value2 </span></div></li><li class="li1"><div class="de1"><span class="kw2">var</span> parameters = queryString.<span class="me1">split</span><span class="br0">(</span><span class="st0">"&amp;"</span><span class="br0">)</span>; </div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="kw2">var</span> pos, paraName, paraValue; </div></li><li class="li1"><div class="de1"><span class="kw1">for</span><span class="br0">(</span><span class="kw2">var</span> i=<span class="nu0">0</span>; i&lt;parameters.<span class="me1">length</span>; i++<span class="br0">)</span></div></li><li class="li2"><div class="de2"><span class="br0">{</span></div></li><li class="li1"><div class="de1"><span class="co1">// 获取等号位置 </span></div></li><li class="li1"><div class="de1">        pos = parameters<span class="br0">[</span>i<span class="br0">]</span>.<span class="me1">indexOf</span><span class="br0">(</span><span class="st0">'='</span><span class="br0">)</span>; </div></li><li class="li1"><div class="de1"><span class="kw1">if</span><span class="br0">(</span>pos == <span class="nu0">-1</span><span class="br0">)</span><span class="br0">{</span><span class="kw1">continue</span>; <span class="br0">}</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li2"><div class="de2"><span class="co1">// 获取name 和 value </span></div></li><li class="li1"><div class="de1">        paraName = parameters<span class="br0">[</span>i<span class="br0">]</span>.<span class="me1">substring</span><span class="br0">(</span><span class="nu0">0</span>, pos<span class="br0">)</span>; </div></li><li class="li1"><div class="de1">        paraValue = parameters<span class="br0">[</span>i<span class="br0">]</span>.<span class="me1">substring</span><span class="br0">(</span>pos + <span class="nu0">1</span><span class="br0">)</span>; </div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="co1">// 如果查询的name等于当前name，就返回当前值，同时，将链接中的+号还原成空格 </span></div></li><li class="li2"><div class="de2"><span class="kw1">if</span><span class="br0">(</span>paraName == <span class="kw3">name</span><span class="br0">)</span></div></li><li class="li1"><div class="de1"><span class="br0">{</span></div></li><li class="li1"><div class="de1"><span class="kw1">return</span> unescape<span class="br0">(</span>paraValue.<span class="me1">replace</span><span class="br0">(</span><span class="re0">/\+/g</span>, <span class="st0">" "</span><span class="br0">)</span><span class="br0">)</span>; </div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li><li class="li2"><div class="de2"><span class="kw1">return</span><span class="st0">''</span>; </div></li><li class="li1"><div class="de1"><span class="br0">}</span>; </div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="co1">//http://localhost/test.html?aa=bb&amp;test=cc+dd&amp;ee=ff </span></div></li><li class="li1"><div class="de1"><span class="kw3">alert</span><span class="br0">(</span>getQueryString<span class="br0">(</span><span class="st0">'test'</span><span class="br0">)</span><span class="br0">)</span>; </div></li><li class="li2"><div class="de2"><span class="co1">//--&gt; </span></div></li><li class="li1"><div class="de1">&lt;/script&gt; </div></li></ol></pre></div><img src ="http://www.cnitblog.com/yhf119/aggbug/23781.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-03-09 11:07 <a href="http://www.cnitblog.com/yhf119/archive/2007/03/09/23781.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ASP 字符真实长度函数</title><link>http://www.cnitblog.com/yhf119/archive/2007/03/03/23526.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Sat, 03 Mar 2007 09:26:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/03/03/23526.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/23526.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/03/03/23526.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/23526.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/23526.html</trackback:ping><description><![CDATA[function getStrLength(strTemp)'用於求中英文字符串的长度<br />    strTemp=replace(strTemp,"&amp;quot;","""")<br />    dim DBCS<br />    DBCS = (len("中文")=2)  '双字节字符集(DBCS)<br />    if DBCS then<br />        strlen=len(strTemp)<br />        trueLen=strlen<br />        dim i<br />        for i=1 to strlen<br />            c=asc(mid(strTemp,i,1))<br />            if c&lt;0 or c&gt;255 then<br />                trueLen=trueLen+1<br />            end if<br />        next<br />        getStrLength=Cint(trueLen/2)<br />    else <br />        getStrLength=len(strTemp)<br />    end if<br />end function<br /><br />function convert_to_fit_lenght(titleTemp,lenTemp)<br />    dim l<br />    l=1.0<br />    dim ch<br />    returnlength=1<br />    do while Abs(Int(-l))&lt;lenTemp and returnlength&lt;=len(titleTemp)<br />        ch=mid(titleTemp,returnlength,1)<br />        if asc(ch) &lt; 0 or asc(ch) &gt; 255 then<br />            l=l+1<br />        else<br />            l=l+0.5<br />        end if<br />        returnlength=returnlength+1<br />    loop<br />    convert_to_fit_lenght = returnlength<br />end function<br /><br />function myLeft(titleTemp,lenTemp)<br />    myLeft = Left(titleTemp,convert_to_fit_lenght(titleTemp,lenTemp))<br />end function<br /><img src ="http://www.cnitblog.com/yhf119/aggbug/23526.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-03-03 17:26 <a href="http://www.cnitblog.com/yhf119/archive/2007/03/03/23526.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C# 简繁体转换</title><link>http://www.cnitblog.com/yhf119/archive/2007/01/20/22094.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Sat, 20 Jan 2007 01:44:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2007/01/20/22094.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/22094.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2007/01/20/22094.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/22094.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/22094.html</trackback:ping><description><![CDATA[
		<div class="textbox-title">
				<h4>简繁体转换</h4>
				<div class="textbox-label">[ 2005-07-15 23:49:19 | 作者: <a href="http://www.rainsts.net/user.asp?act=view&amp;id=2">yuhen</a> ] </div>
		</div>
		<div class="textbox-fontsize">字号: <a title="字号: 大" href="javascript:setFontSize(14)">大</a> | <a title="字号: 中" href="javascript:setFontSize(11)">中</a> | <a title="字号: 小" href="javascript:setFontSize(9)">小</a></div>
		<div class="textbox-content" id="textboxContent">Strings.StrConv 这个方法还是博客园的一个兄弟发现的，我添了几行代码。做个记录，免得以后忘记。<br />我的分词组件可以利用这个临时解决一下繁体分词了。 <img alt="[smile]" src="http://www.rainsts.net/styles/default/images/smilies/icon_smile.gif" border="0" /><br /><br />添加 Microsoft Visual Basic.NET Runtime 引用。<br /><div class="code">using System;<br />using System.IO;<br />using System.Text;<br />using Microsoft.VisualBasic;<br /><br />namespace Rainsoft.Text<br />{<br />  /// &lt;summary&gt;<br />  /// 字符串编码转换类<br />  /// &lt;/summary&gt;<br />  public class StringEncoding<br />  {<br />    private StringEncoding()<br />    {<br />    }<br /><br />    /// &lt;summary&gt;<br />    /// 将字符串转换为简体中文<br />    /// &lt;/summary&gt;<br />    public static string ToSimplifiedChinese(string s)<br />    {<br />      return Microsoft.VisualBasic.Strings.StrConv(s, VbStrConv.SimplifiedChinese, 0);<br />    }<br /><br />    /// &lt;summary&gt;<br />    /// 将文件转换为简体中文<br />    /// &lt;/summary&gt;<br />    /// &lt;param name="filename"&gt;源文件名&lt;/param&gt;<br />    /// &lt;param name="encoding"&gt;源文件字符编码&lt;/param&gt;<br />    /// &lt;param name="outFilename"&gt;目标文件名&lt;/param&gt;<br />    /// &lt;param name="outEncoding"&gt;目标文件字符编码&lt;/param&gt;<br />    /// &lt;example&gt;<br />    /// &lt;code&gt;<br />    /// ToSimplifiedChinese("big5.txt", Encoding.GetEncoding("big5"), "gb.txt", Encoding.GetEncoding("gb2312"));<br />    /// ToSimplifiedChinese("big5.txt", Encoding.GetEncoding("big5"), "gb.txt", Encoding.UTF8);<br />    /// &lt;/code&gt;<br />    /// &lt;/example&gt;<br />    public static void ToSimplifiedChinese(string filename, Encoding encoding, string outFilename, Encoding outEncoding)<br />    {<br />      StreamReader r = new StreamReader(filename, encoding);<br />      StreamWriter w = new StreamWriter(outFilename, false, outEncoding);<br />      try<br />      {<br />        w.Write(Strings.StrConv(r.ReadToEnd(), VbStrConv.SimplifiedChinese, 0));<br />        w.Flush();<br />      }<br />      finally<br />      {<br />        w.Close();<br />        r.Close();<br />      }<br />    }<br /><br />    /// &lt;summary&gt;<br />    /// 将字符串转换为繁体中文<br />    /// &lt;/summary&gt;<br />    public static string ToTraditionalChinese(string s)<br />    {<br />      return Microsoft.VisualBasic.Strings.StrConv(s, VbStrConv.TraditionalChinese, 0);<br />    }<br /><br />    /// &lt;summary&gt;<br />    /// 将文件转换为繁体中文<br />    /// &lt;/summary&gt;<br />    /// &lt;param name="filename"&gt;源文件名&lt;/param&gt;<br />    /// &lt;param name="encoding"&gt;源文件字符编码&lt;/param&gt;<br />    /// &lt;param name="outFilename"&gt;目标文件名&lt;/param&gt;<br />    /// &lt;param name="outEncoding"&gt;目标文件字符编码&lt;/param&gt;<br />    /// &lt;example&gt;<br />    /// &lt;code&gt;<br />    /// ToTraditionalChinese("gb.txt", Encoding.GetEncoding("gb2312"), "gb.txt", Encoding.GetEncoding("big5"));<br />    /// ToTraditionalChinese("gb.txt", Encoding.GetEncoding("gb2312"), "gb.txt", Encoding.UTF8);<br />    /// &lt;/code&gt;<br />    /// &lt;/example&gt;<br />    public static void ToTraditionalChinese(string filename, Encoding encoding, string outFilename, Encoding outEncoding)<br />    {<br />      StreamReader r = new StreamReader(filename, encoding);<br />      StreamWriter w = new StreamWriter(outFilename, false, outEncoding);<br />      try<br />      {<br />        w.Write(Strings.StrConv(r.ReadToEnd(), VbStrConv.TraditionalChinese, 0));<br />        w.Flush();<br />      }<br />      finally<br />      {<br />        w.Close();<br />        r.Close();<br />      }<br />    }<br />  }<br />}</div></div>
<img src ="http://www.cnitblog.com/yhf119/aggbug/22094.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2007-01-20 09:44 <a href="http://www.cnitblog.com/yhf119/archive/2007/01/20/22094.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ftp命令pasv返回值含意</title><link>http://www.cnitblog.com/yhf119/archive/2006/06/17/12419.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Sat, 17 Jun 2006 06:54:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2006/06/17/12419.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/12419.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2006/06/17/12419.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/12419.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/12419.html</trackback:ping><description><![CDATA[返回值是如下格式：<br /><br />Entering Passive Mode (172,16,62,72,17,118)<br /><br /><pre>表示32位的IP地址和16位的TCP端口号。
上面的信息以8位为一组，逗号间隔十进制传输。
就是ip为172.16.62.72, port高位为0x11,低位为0x76,即port是 4470<br /><br /><br /><br /><br /><br />出处：<a href="http://www.cndiy8.com/ask12/ask176578.htm">http://www.cndiy8.com/ask12/ask176578.htm</a></pre><img src ="http://www.cnitblog.com/yhf119/aggbug/12419.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2006-06-17 14:54 <a href="http://www.cnitblog.com/yhf119/archive/2006/06/17/12419.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>收缩SQLServer2000的数据库日志</title><link>http://www.cnitblog.com/yhf119/archive/2006/04/18/9302.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 18 Apr 2006 02:42:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2006/04/18/9302.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/9302.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2006/04/18/9302.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/9302.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/9302.html</trackback:ping><description><![CDATA[用命令行：<br /><br />针对数据库日志文件，比如：数据库名：PUB；日志文件名PUB_LOG，目前为100M，要压缩到10M <br />第一步：截断事务日志 <br />在SQL查询分析器中，执行BACKUP LOG PUB WITH TRUNCATE_ONLY <br />第二步：收缩数据库日志到指定大小 <br />在SQL查询分析器中，执行DBCC SHRINKFILE (PUB_LOG,10) <br /><br />用企业管理器：<br /><br />右单击要收缩的数据库，选所有任务，收缩数据库，点下面的“文件”，在下拉框选择要收缩的文件（Data文件或者Log文件），确定就行。要压缩多个文件就重复操作几次。<img src ="http://www.cnitblog.com/yhf119/aggbug/9302.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2006-04-18 10:42 <a href="http://www.cnitblog.com/yhf119/archive/2006/04/18/9302.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]浅谈WebForm中DataGrid的ItemDataBound事件 </title><link>http://www.cnitblog.com/yhf119/archive/2006/03/30/8318.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Thu, 30 Mar 2006 09:52:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2006/03/30/8318.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/8318.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2006/03/30/8318.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/8318.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/8318.html</trackback:ping><description><![CDATA[原文:http://dev.csdn.net/article/64/64160.shtm<br /><br /><span id="ArticleContent1_ArticleContent1_lblContent"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"> 
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">　　当项被数据绑定到</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'"><span lang="EN-US">DataGrid </span></span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">控件后，将引发</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'"><span lang="EN-US" style="mso-bidi-font-weight: bold">ItemDataBound</span><span lang="EN-US"></span></span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">事件。此事件提供了在客户端显示数据项之前访问该数据项的最后机会。</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">利用</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'">DataGrid</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">的</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">ItemDataBound</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">事件，</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">我们可以轻松实现一些实用的功能。</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">private</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="COLOR: blue">void</span> DataGrid1_ItemDataBound(<span style="COLOR: blue">object</span> sender, DataGridItemEventArgs e)<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">{<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">    </span><span style="COLOR: blue">if</span> (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">    </span>{<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span>DataRowView drv = (DataRowView)e.Item.DataItem;<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span><span style="COLOR: green">//</span></span><span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">设置每一行的序号</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span><span style="COLOR: blue">int</span> num = e.Item.ItemIndex + 1;<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span>e.Item.Cells[0].Text = num.ToString();<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span><span style="COLOR: green">//</span></span><span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">“性别”字段在数据库中是以“</span><?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /?><st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="0" unitname="”"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">0</span><span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">”</span></st1:chmetcnv><span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">和“</span><st1:chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="1" unitname="”"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">1</span><span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">”</span></st1:chmetcnv><span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">存储的，现在以“男”和“女”展现给用户</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span><span style="COLOR: blue">int</span> sex = Convert.ToInt32(drv["FSex"]);<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span>e.Item.Cells[2].Text = (sex == 0 ? "</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">男</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">" : "</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">女</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">");<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span><span style="COLOR: green">//</span></span><span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt">将“婚否”字段绑定到</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> CheckBox<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span><span style="COLOR: blue">int</span> married = Convert.ToInt32(drv["FMarried"]);<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span>CheckBox chk = (CheckBox)e.Item.FindControl("CheckBox1");<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span>chk.Checked = (married == 0 ? <span style="COLOR: blue">false</span> : <span style="COLOR: blue">true</span>);<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">    </span>}<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">}<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">效果如下图所示：</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'"><o:p></o:p></span></p><p align="center"><img alt="" hspace="0" src="http://blog.csdn.net/images/blog_csdn_net/doubon/89950/o_ItemDataBound.gif" align="baseline" border="0" /></p></span></span><br /><div style="FONT-SIZE: 14px; LINE-HEIGHT: 25px"><strong>原作者Blog：</strong><a id="ArticleContent1_ArticleContent1_AuthorBlogLink" href="http://blog.csdn.net/doubon/" target="_blank">http://blog.csdn.net/doubon/</a><br /><br /></div><img src ="http://www.cnitblog.com/yhf119/aggbug/8318.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2006-03-30 17:52 <a href="http://www.cnitblog.com/yhf119/archive/2006/03/30/8318.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Access数据库的存储上限</title><link>http://www.cnitblog.com/yhf119/archive/2006/03/28/8152.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 28 Mar 2006 02:03:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2006/03/28/8152.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/8152.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2006/03/28/8152.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/8152.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/8152.html</trackback:ping><description><![CDATA[
		<strong>数据库<br />属性                                                                          最大值<br /></strong>Microsoft Access 数据库 (.mdb) 文件大小 2G 字节减去系统对象所需的空间。<br />数据库中的对象个数                                        32,768<br />模块（包括“内含模块”属性为“是”的窗体和报表） 1,000<br />对象名称中的字符数                                        64<br />密码的字符个数                                                14<br />用户名或组名的字符个数                                20<br />并发用户的个数                                                255<br /><br /><font size="3"><strong>表</strong><br /></font><br />属性 最大值<br />表名的字符个数 64<br />字段名的字符个数 64<br />表中字段的个数 255<br />打开表的个数 2048；实际可打开的表的数目可能会少一些，因为 Microsoft Access 还要打开一些内部的表。<br />表的大小 2G 字节减去系统对象所需的空间<br />“文本”字段的字符个数 255<br />“备注”字段的字符个数 通过用户界面输入为 65,535；以编程方式输入时为 1G 字节的字符存储。<br />“OLE 对象”字段的大小 1G 字节<br />表中的索引个数 32<br />索引中的字段个数 10<br />有效性消息的字符个数 255<br />有效性规则的字符个数 2,048<br />表或字段说明的字符个数 255<br />记录的字符个数（除“备注”字段和“OLE 对象”字段外） 2,000<br />字段属性设置的字符个数 255<br /><br /><strong><font size="3">查询</font></strong><br /><br />属性 最大值<br />实施关系的个数 每个表为 32 减去表中不包含在关系中的字段或字段组合的索引个数<br />查询中的表的个数 32<br />记录集中的字段个数 255<br />记录集大小 1G 字节<br />排序限制 255 个字符（一个或一个以上字段）<br />嵌套查询的层次数 50<br />查询设计网格一个单元格中的字符个数 1,024<br />参数查询的参数字符个数 255<br />Where 或 HAVING 子句中 AND 的个数 99<br />SQL 语句中的字符个数 约为 64,000<br /><br /><font size="3"><strong>窗体和报表</strong><br /></font><br />属性 最大值<br />标签中的字符个数 2,048<br />文本框中的字符个数 65,535<br />窗体或报表宽度 22 英寸（55.87 厘米）<br />节高度 22 英寸（55.87 厘米）<br />所有节加上节页眉的高度（在“设计”视图中） 200 英寸（508 厘米）<br />窗体或报表的最大嵌套层数 7<br />报表中可作为排序或分组依据的字段或表达式个数 10<br />报表中页眉和页脚的个数 1 对报表页眉/报表页脚，1 对页面页眉/页面页脚，10 对组页眉/组页脚<br />报表的打印页数 65,536<br />可添加到窗体或报表的控件和节的个数 754<br />SQL 语句中作为窗体、报表或控件的“记录源”或“行来源”属性的字符个数（适用于 .mdb 和 .adp） 32,750<br /><br /><strong>宏</strong><br /><br />属性 最大值<br />宏中的操作个数 999<br />条件中的字符个数 255<br />备注中的字符个数 255<br />操作参数中的字符个数 255 <br /><br /><br /><br /><strong>Microsoft Access 项目规格</strong><br /><strong>Access 项目</strong><br /><br />属性 最大值<br />Microsoft Access 项目 (.adp) 中的对象数目 32,768<br />模块（包括“内含模块”属性为“是”的窗体和报表） 1,000<br />对象名称中的字符数 64<br />表中的索引个数 250 (Microsoft SQL Server 6.5)<br />1024（Microsoft SQL Server 7.0 和 2000）<br /><br /><br /><br /><strong>Microsoft SQL Server 数据库</strong><br /><br />SQL Server 文档中描述了 Microsoft SQL Server 最大容量规格。有关 SQL Server 联机丛书的详细信息，请参见 Microsoft Developer's Network Web 站点。<br /><br /><br />注意 使用该主题中的超链接会跳转到 Web 上，但随时可以切换回“帮助”。<br /><br /><br /><strong>窗体和报表</strong><br /><br />属性 最大值<br />标签中的字符个数 2,048<br />文本框中的字符个数 65,535<br />窗体或报表宽度 22 英寸（55.87 厘米）<br />节高度 22 英寸（55.87 厘米）<br />所有节加上节页眉的高度（在“设计”视图中） 200 英寸（508 厘米）<br />窗体或报表的最大嵌套层数 7<br />报表中可作为排序或分组依据的字段或表达式个数 10<br />报表中页眉和页脚的个数 1 对报表页眉/报表页脚，1 对页面页眉/页面页脚，10 对组页眉/组页脚<br />报表的打印页数 65,536<br />可添加到窗体或报表的控件和节的个数 754<br />SQL 语句中作为窗体、报表或控件的“记录源”或“行来源”属性的字符个数（适用于 .mdb 和 .adp） 32,750<br /><br /><br /><strong>宏</strong><br /><br />属性 最大值<br />宏中的操作个数 999<br />条件中的字符个数 255<br />备注中的字符个数 255<br />操作参数中的字符个数 255 <br /><img src ="http://www.cnitblog.com/yhf119/aggbug/8152.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2006-03-28 10:03 <a href="http://www.cnitblog.com/yhf119/archive/2006/03/28/8152.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IE和Foxfire中XHTML+CSS兼容性解决方案小集</title><link>http://www.cnitblog.com/yhf119/archive/2006/03/01/7050.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Wed, 01 Mar 2006 08:21:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2006/03/01/7050.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/7050.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2006/03/01/7050.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/7050.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/7050.html</trackback:ping><description><![CDATA[　　使用XHTML＋CSS构架好处不少，但也确实存在一些问题，不论是因为使用不熟练还是思路不清晰，我就先把一些我遇到的问题写在下面，省的大家四处找^^<BR><BR>　　1.在mozilla firefox和IE中的BOX模型解释不一致导致相差2px解决方法：<PRE class=CodeSamp>div{margin:30px!important;margin:28px;}</PRE>注意这两个margin的顺序一定不能写反，据阿捷的说法!important这个属性IE不能识别，但别的浏览器可以识别。所以在IE下其实解释成这样：<PRE class=CodeSamp>div{maring:30px;margin:28px}</PRE>重复定义的话按照最后一个来执行，所以不可以只写margin:XXpx!important;<BR><BR>　　2.IE5和IE6的BOX解释不一致IE5下div{width:300px;margin:0 10px 0 10px;}div的宽度会被解释为300px-10px(右填充)-10px(左填充)最终div的宽度为280px，而在IE6和其他浏览器上宽度则是以300px+10px(右填充)+10px(左填充)=320px来计算的。这时我们可以做如下修改<PRE class=CodeSamp>div{width:300px!important;width  /**/:340px;margin:0  10px  0  10px}</PRE>，关于这个/**/是什么我也不太明白，只知道IE5和firefox都支持但IE6不支持，如果有人理解的话，请告诉我一声，谢了！：）<BR><BR>　　3.ul标签在Mozilla中默认是有padding值的,而在IE中只有margin有值所以先定义<PRE class=CodeSamp>ul{margin:0;padding:0;}</PRE>就能解决大部分问题<BR><BR>　　4.关于脚本，在xhtml1.1中不支持language属性，只需要把代码改为<PRE class=CodeSamp>&lt;script  type="text/javascript"&gt;</PRE>就可以了<BR><BR><BR>如果你在BOX容器里使float和text-align的方向设为一致<PRE class=CodeSamp>{float:left;text-align:left;margin:0 0 0 200px;}</PRE>那么对不起，IE会把左边这个距离翻倍！也就是说400px！<BR>我们可做如下修改:<PRE class=CodeSamp>{float:left;text-align:left;margin:0 0 0 200px;display:inline;}</PRE><BR><img src ="http://www.cnitblog.com/yhf119/aggbug/7050.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2006-03-01 16:21 <a href="http://www.cnitblog.com/yhf119/archive/2006/03/01/7050.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在客户端获取服务器控件</title><link>http://www.cnitblog.com/yhf119/archive/2006/02/28/7018.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 28 Feb 2006 00:45:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2006/02/28/7018.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/7018.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2006/02/28/7018.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/7018.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/7018.html</trackback:ping><description><![CDATA[Document.getElementByID("&lt;%ServerControlID.ClientID%&gt;")<img src ="http://www.cnitblog.com/yhf119/aggbug/7018.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2006-02-28 08:45 <a href="http://www.cnitblog.com/yhf119/archive/2006/02/28/7018.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C#实现的18位身份证格式验证类[转]</title><link>http://www.cnitblog.com/yhf119/archive/2006/02/24/6917.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Fri, 24 Feb 2006 09:57:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2006/02/24/6917.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/6917.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2006/02/24/6917.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/6917.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/6917.html</trackback:ping><description><![CDATA[&nbsp; 18位身份证标准在国家质量技术监督局于1999年7月1日实施的GB11643-1999《公民身份号码》中做了明确的规定。 GB11643-1999《公民身份号码》为GB11643-1989《社会保障号码》的修订版，其中指出将原标准名称"社会保障号码"更名为"公民身份号码"，另外GB11643-1999《公民身份号码》从实施之日起代替GB11643-1989。GB11643-1999《公民身份号码》主要内容如下：<BR>一、范围<BR>&nbsp;&nbsp;&nbsp;&nbsp; 该标准规定了公民身份号码的编码对象、号码的结构和表现形式，使每个编码对象获得一个唯一的、不变的法定号码。<BR>二、编码对象<BR>&nbsp;&nbsp;&nbsp;&nbsp; 公民身份号码的编码对象是具有中华人民共和国国籍的公民。<BR>三、号码的结构和表示形式<BR>1、号码的结构<BR>&nbsp;&nbsp;&nbsp; 公民身份号码是特征组合码，由十七位数字本体码和一位校验码组成。排列顺序从左至右依次为：六位数字地址码，八位数字出生日期码，三位数字顺序码和一位数字校验码。<BR>2、地址码<BR>&nbsp;&nbsp;&nbsp; 表示编码对象常住户口所在县(市、旗、区)的行政区划代码，按GB/T2260的规定执行。<BR>3、出生日期码<BR>&nbsp;&nbsp;&nbsp; 表示编码对象出生的年、月、日，按GB/T7408的规定执行，年、月、日代码之间不用分隔符。<BR>4、顺序码<BR>&nbsp;&nbsp;&nbsp;&nbsp; 表示在同一地址码所标识的区域范围内，对同年、同月、同日出生的人编定的顺序号，顺序码的奇数分配给男性，偶数分配给女性。<BR>5、校验码<BR>（1）十七位数字本体码加权求和公式<BR>S = Sum(Ai * Wi), i = 0, ... , 16 ，先对前17位数字的权求和<BR>Ai:表示第i位置上的身份证号码数字值<BR>Wi:表示第i位置上的加权因子<BR>Wi: 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 
<P>（2）计算模<BR>Y = mod(S, 11)</P>
<P>（3）通过模得到对应的校验码<BR>Y: 0 1 2 3 4 5 6 7 8 9 10<BR>校验码: 1 0 X 9 8 7 6 5 4 3 2<BR>四、举例如下：<BR>北京市朝阳区: 11010519491231002X<BR>广东省汕头市: 440524188001010014</P>
<P><BR></P>
<P>&nbsp;&nbsp;&nbsp; 根据〖中华人民共和国国家标准 GB 11643-1999〗中有关公民身份号码的规定，公民身份号码是特征组合码，由十七位数字本体码和一位数字校验码组成。排列顺序从左至右依次为：六位数字地址码，八位数字出生日期码，三位数字顺序码和一位数字校验码。 </P>
<P>&nbsp;&nbsp;&nbsp; 地址码表示编码对象常住户口所在县(市、旗、区)的行政区划代码。生日期码表示编码对象出生的年、月、日，其中年份用四位数字表示，年、月、日之间不用分隔符。顺序码表示同一地址码所标识的区域范围内，对同年、月、日出生的人员编定的顺序号。顺序码的奇数分给男性，偶数分给女性。校验码是根据前面十七位数字码，按照ISO 7064:1983.MOD 11-2校验码计算出来的检验码。下面举例说明该计算方法。&nbsp; </P>
<P>&nbsp;&nbsp;&nbsp; 15位的身份证编码首先把出生年扩展为4位，简单的就是增加一个19，但是这对于1900年出生的人不使用（这样的寿星不多了）</P>
<P>&nbsp;&nbsp;&nbsp; 某男性公民身份号码本体码为34052419800101001，首先按照公式⑴计算： </P>
<P>∑(ai×Wi)(mod 11)……………………………………(1) </P>
<P>公式(1)中：<BR>i----表示号码字符从由至左包括校验码在内的位置序号；<BR>ai----表示第i位置上的号码字符值；<BR>Wi----示第i位置上的加权因子，其数值依据公式Wi=2（n-1）(mod 11)计算得出。 </P>
<P>i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 18 17 16 15 14 13 12 11 10&nbsp; 9&nbsp; 8&nbsp; 7&nbsp; 6&nbsp; 5&nbsp; 4&nbsp; 3&nbsp; 2&nbsp; 1 </P>
<P>ai&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp; 4&nbsp; 0&nbsp; 5&nbsp; 2&nbsp; 4&nbsp; 1&nbsp; 9&nbsp; 8&nbsp; 0&nbsp; 0&nbsp; 1&nbsp; 0&nbsp; 1&nbsp; 0&nbsp; 0&nbsp; 1 a1 </P>
<P>Wi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7&nbsp; 9 10&nbsp; 5&nbsp; 8&nbsp; 4&nbsp; 2&nbsp; 1&nbsp; 6&nbsp; 3&nbsp; 7&nbsp; 9 10&nbsp; 5&nbsp; 8&nbsp; 4&nbsp; 2&nbsp; 1 </P>
<P>ai×Wi&nbsp; 21 36&nbsp; 0 25 16 16&nbsp; 2&nbsp; 9 48&nbsp; 0&nbsp; 0&nbsp; 9&nbsp; 0&nbsp; 5&nbsp; 0&nbsp; 0&nbsp; 2 a1 </P>
<P>根据公式(1)进行计算： </P>
<P>∑(ai×Wi) =（21+36+0+25+16+16+2+9+48++0+0+9+0+5+0+0+2) = 189 </P>
<P>189 ÷ 11 = 17 + 2/11 </P>
<P>∑(ai×Wi)(mod 11) = 2 </P>
<P>&nbsp;&nbsp;&nbsp; 然后根据计算的结果，从下面的表中查出相应的校验码，其中X表示计算结果为10： </P>
<P>∑(ai×WI)(mod 11)&nbsp;&nbsp; 0 1 2 3 4 5 6 7 8 9 10 <BR>校验码字符值ai&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 0 X 9 8 7 6 5 4 3&nbsp; 2<BR>&nbsp;&nbsp;&nbsp; 根据上表，查出计算结果为2的校验码为所以该人员的公民身份号码应该为 34052419800101001X。</P>
<P><FONT color=#0000ff>以上是转载的（sorry忘了哪里找过来的）,以下是根据原文写的一个校验类，并自动将15位转换成18位.</FONT><BR>---------------------------------------------------------------------------------<BR><FONT color=#000000>using System;<BR>using System.Text;<BR>using System.Text.RegularExpressions;<BR>namespace Leisang<BR>{<BR>&nbsp;/// &lt;summary&gt;<BR>&nbsp;/// CID 的摘要说明。<BR>&nbsp;/// &lt;/summary&gt;<BR>&nbsp;public class IdentityCard<BR>&nbsp;{<BR>&nbsp;&nbsp;private string cid_;<BR>&nbsp;&nbsp;private string errmsg;<BR>&nbsp;&nbsp;private string[] aCity;<BR>&nbsp;&nbsp;public IdentityCard()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;aCity = new string[]{null,null,null,null,null,null,null,null,null,null,null,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"北京","天津 ","河北","山西","内蒙古",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,null,null,null,null,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"辽宁","吉林","黑龙江",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,null, null,null,null,null,null,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"上海","江苏","浙江","安微","福建","江西","山东",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,null, null,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"河南","湖北","湖南","广东","广西","海南",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,null,null,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"重庆","四川","贵州","云南","西藏",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,null,null,null,null,null,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"陕西","甘肃","青海","宁夏","新疆",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,null, null,null,null,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"台湾",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,null,null,null,null,null,null,null,null,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"香港","澳门",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,null,null,null,null,null,null,null,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"国外"};<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;public bool Check(string CardID)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;CID=CardID;<BR>&nbsp;&nbsp;&nbsp;return Check();<BR>&nbsp;&nbsp;}</FONT></P>
<P><FONT color=#000000>&nbsp;&nbsp;public bool Check()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//判断位数<BR>&nbsp;&nbsp;&nbsp;if(CID.Length==15)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return Check15();<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;else if(CID.Length==18)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return Check18(CID);<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;ErrMsg="身份证位数不正确";<BR>&nbsp;&nbsp;&nbsp;&nbsp;return false;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}</FONT></P>
<P><FONT color=#000000>&nbsp;&nbsp;public bool Check18(string cid)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;double iSum=0;<BR>&nbsp;&nbsp;&nbsp;//string info="";<BR>&nbsp;&nbsp;&nbsp;System.Text.RegularExpressions.Regex rg = new System.Text.RegularExpressions.Regex(@"^\d{17}(\d|x)$");<BR>&nbsp;&nbsp;&nbsp;System.Text.RegularExpressions.Match mc = rg.Match(cid);<BR>&nbsp;&nbsp;&nbsp;if(!mc.Success)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;ErrMsg="身份证输入错误";<BR>&nbsp;&nbsp;&nbsp;&nbsp;return false;<BR>&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;cid = cid.ToLower();<BR>&nbsp;&nbsp;&nbsp;cid = cid.Replace("x","a");<BR>&nbsp;&nbsp;&nbsp;if(aCity[int.Parse(cid.Substring(0,2))]==null)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;ErrMsg= "非法地区";<BR>&nbsp;&nbsp;&nbsp;&nbsp;return false;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;try<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;DateTime.Parse(cid.Substring(6,4)+"-"+cid.Substring(10,2)+"-"+cid.Substring(12,2));<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;catch<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;ErrMsg= "非法生日";<BR>&nbsp;&nbsp;&nbsp;&nbsp;return false;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;for(int i=17;i&gt;=0;i--)<BR>&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;iSum +=(System.Math.Pow(2,i)%11)*int.Parse(cid[17-i].ToString(),System.Globalization.NumberStyles.HexNumber);</FONT></P>
<P><FONT color=#000000>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;if(iSum%11!=1)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;ErrMsg="非法证号";<BR>&nbsp;&nbsp;&nbsp;&nbsp;return false;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;//return "";<BR>&nbsp;&nbsp;&nbsp;string xx;<BR>&nbsp;&nbsp;&nbsp;int sex=int.Parse(cid.Substring(16,1))%2;<BR>&nbsp;&nbsp;&nbsp;if(sex==1)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;xx="男";<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;xx="女";<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;ErrMsg=(aCity [int.Parse(cid.Substring(0,2))]+","+cid.Substring(6,4)+"-"+cid.Substring(10,2) +"-"+cid.Substring(12,2)+","+xx);<BR>&nbsp;&nbsp;&nbsp;return true;<BR>&nbsp;&nbsp;}</FONT></P>
<P><FONT color=#000000>&nbsp;&nbsp;public bool Check15()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;string[] verifyID=new string[]{"0","1","2","3","4","5","6","7","8","9","x"};<BR>&nbsp;&nbsp;&nbsp;CID=CID.Substring(0,6)+"19"+CID.Substring(6,9);<BR>&nbsp;&nbsp;&nbsp;foreach(string vid in verifyID)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;bool result=Check18(CID+vid);<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(result)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ErrMsg+=" your Card ID:"+CID+vid;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;return false;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;public string CID<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;get{return cid_;}<BR>&nbsp;&nbsp;&nbsp;set{cid_=value;}<BR>&nbsp;&nbsp;}</FONT></P>
<P><FONT color=#000000>&nbsp;&nbsp;public string ErrMsg<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;get{return errmsg;}<BR>&nbsp;&nbsp;&nbsp;set{errmsg=value;}<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>}<BR><BR><BR>原文:http://blog.csdn.net/leisang/archive/2004/10/30/159875.aspx<BR><BR></FONT></P><img src ="http://www.cnitblog.com/yhf119/aggbug/6917.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2006-02-24 17:57 <a href="http://www.cnitblog.com/yhf119/archive/2006/02/24/6917.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IIS6 中"ASP 0201 错误 无效的默认脚本语言" 的解决方法</title><link>http://www.cnitblog.com/yhf119/archive/2006/02/21/6788.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 21 Feb 2006 09:43:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2006/02/21/6788.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/6788.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2006/02/21/6788.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/6788.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/6788.html</trackback:ping><description><![CDATA[<P><SPAN class=oblog_text>今天突然打开任意Asp文件,都会提示:</P>
<P>Active Server Pages 错误 'ASP 0201' <BR><BR>&nbsp; 无效的默认脚本语言 <BR><BR>&nbsp; 为此应用程序指定的默认脚本语言无效。<BR><BR>平台: Windows 2003 IIS 6.0<BR><BR>解决方法（对我的电脑适用，不知对别人是否有效，仅作参考）：<BR><BR>1、在控制面板里，删除IIS组件。<BR><BR>2、删除C:\Inetpub目录。<BR><BR>3、重新安装IIS。<BR><BR>4、如果不行就试一下IIS管理器里的“重新启动IIS”<BR><BR></P></SPAN><img src ="http://www.cnitblog.com/yhf119/aggbug/6788.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2006-02-21 17:43 <a href="http://www.cnitblog.com/yhf119/archive/2006/02/21/6788.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IIS6.0服务器架站无法访问解决方案总结</title><link>http://www.cnitblog.com/yhf119/archive/2006/02/21/6768.html</link><dc:creator>杨</dc:creator><author>杨</author><pubDate>Tue, 21 Feb 2006 02:08:00 GMT</pubDate><guid>http://www.cnitblog.com/yhf119/archive/2006/02/21/6768.html</guid><wfw:comment>http://www.cnitblog.com/yhf119/comments/6768.html</wfw:comment><comments>http://www.cnitblog.com/yhf119/archive/2006/02/21/6768.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yhf119/comments/commentRss/6768.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yhf119/services/trackbacks/6768.html</trackback:ping><description><![CDATA[很多朋友在用IIS6架网站的时候遇到不少问题，而这些问题有些在过去的IIS5里面就遇到过，有些是新出来的，俺忙活了一下午，做了很多次试验，结合以前的排错经验，做出了这个总结，希望能给大家帮上忙：）<BR><BR>问题1：未启用父路径<BR>症状举例：<BR>Server.MapPath() 错误 'ASP 0175 : 80004005' <BR>不允许的 Path 字符 <BR>/0709/dqyllhsub/news/OpenDatabase.asp，行 4 <BR>在 MapPath 的 Path 参数中不允许字符 '..'。<BR><BR>原因分析：<BR>许多Web页面里要用到诸如../格式的语句（即回到上一层的页面，也就是父路径），而IIS6.0出于安全考虑，这一选项默认是关闭的。<BR><BR>解决方法：<BR>在IIS中 属性-&gt;主目录-&gt;配置-&gt;选项中。把”启用父路径“前面打上勾。确认刷新。 <BR><BR><BR>问题2：ASP的Web扩展配置不当（同样适用于ASP.NET、CGI）<BR><BR>症状举例：<BR>HTTP 错误 404 - 文件或目录未找到。<BR><BR>原因分析：<BR>在IIS6.0中新增了web程序扩展这一选项，你可以在其中对ASP、ASP.NET、CGI、IDC等程序进行允许或禁止，默认情况下ASP等程序是禁止的。<BR><BR>解决方法：<BR>在IIS中的Web服务扩展中选中Active Server Pages，点击“允许”。<BR><BR><BR>问题3：身份认证配置不当<BR><BR>症状举例：<BR>HTTP 错误 401.2 - 未经授权：访问由于服务器配置被拒绝。<BR><BR>原因分析：IIS 支持以下几种 Web 身份验证方法： <BR>匿名身份验证 <BR>IIS 创建 IUSR_计算机名称 帐户（其中 计算机名称 是正在运行 IIS 的服务器的名称），用来在匿名用户请求 Web 内容时对他们进行身份验证。此帐户授予用户本地登录权限。你可以将匿名用户访问重置为使用任何有效的 Windows 帐户。<BR>基本身份验证 <BR>使用基本身份验证可限制对 NTFS 格式 Web 服务器上的文件的访问。使用基本身份验证，用户必须输入凭据，而且访问是基于用户 ID 的。用户 ID 和密码都以明文形式在网络间进行发送。 <BR>Windows 集成身份验证 <BR>Windows 集成身份验证比基本身份验证安全，而且在用户具有 Windows 域帐户的内部网环境中能很好地发挥作用。在集成的 Windows 身份验证中，浏览器尝试使用当前用户在域登录过程中使用的凭据，如果尝试失败，就会提示该用户输入用户名和密码。如果你使用集成的 Windows 身份验证，则用户的密码将不传送到服务器。如果该用户作为域用户登录到本地计算机，则他在访问此域中的网络计算机时不必再次进行身份验证。<BR>摘要身份验证 <BR>摘要身份验证克服了基本身份验证的许多缺点。在使用摘要身份验证时，密码不是以明文形式发送的。另外，你可以通过代理服务器使用摘要身份验证。摘要身份验证使用一种挑战/响应机制（集成 Windows 身份验证使用的机制），其中的密码是以加密形式发送的。<BR>.NET Passport 身份验证 <BR>Microsoft .NET Passport 是一项用户身份验证服务，它允许单一签入安全性，可使用户在访问启用了 .NET Passport 的 Web 站点和服务时更加安全。启用了 .NET Passport 的站点会依靠 .NET Passport 中央服务器来对用户进行身份验证。但是，该中心服务器不会授权或拒绝特定用户访问各个启用了 .NET Passport 的站点。<BR><BR>解决方法：<BR>根据需要配置不同的身份认证（一般为匿名身份认证，这是大多数站点使用的认证方法）。认证选项在IIS的属性-&gt;安全性-&gt;身份验证和访问控制下配置。<BR><BR><BR>问题4：IP限制配置不当<BR><BR>症状举例：<BR>HTTP 错误 403.6 - 禁止访问：客户端的 IP 地址被拒绝。<BR><BR>原因分析：<BR>IIS提供了IP限制的机制，你可以通过配置来限制某些IP不能访问站点，或者限制仅仅只有某些IP可以访问站点，而如果客户端在被你阻止的IP范围内，或者不在你允许的范围内，则会出现错误提示。<BR><BR>解决方法：<BR>进入IIS的属性-&gt;安全性-&gt;IP地址和域名限制。如果要限制某些IP地址的访问，需要选择授权访问，点添加选择不允许的IP地址。反之则可以只允许某些IP地址的访问。<BR><BR><BR>问题5：IUSR账号被禁用<BR><BR>症状举例：<BR>HTTP 错误 401.1 - 未经授权：访问由于凭据无效被拒绝。<BR><BR>原因分析：<BR>由于用户匿名访问使用的账号是IUSR_机器名，因此如果此账号被禁用，将造成用户无法访问。<BR><BR>解决办法：<BR>控制面板-&gt;管理工具-&gt;计算机管理-&gt;本地用户和组，将IUSR_机器名账号启用。<BR><BR><BR>问题6：NTFS权限设置不当<BR><BR>症状举例：<BR>HTTP 错误 401.3 - 未经授权：访问由于 ACL 对所请求资源的设置被拒绝。<BR><BR>原因分析：<BR>Web客户端的用户隶属于user组，因此，如果该文件的NTFS权限不足（例如没有读权限），则会导致页面无法访问。<BR><BR>解决办法：<BR>进入该文件夹的安全选项卡，配置user的权限，至少要给读权限。关于NTFS权限设置这里不再馈述。<BR><BR><BR>问题7：IWAM账号不同步<BR><BR>症状举例：<BR>HTTP 500 - 内部服务器错误<BR><BR>原因分析：<BR>IWAM账号是安装IIS时系统自动建立的一个内置账号。IWAM账号建立后被Active Directory、IIS metabase数据库和COM+应用程序三方共同使用，账号密码被三方分别保存，并由操作系统负责这三方保存的IWAM密码的同步工作。系统对IWAM账号的密码同步工作有时会失效，导致IWAM账号所用密码不统一。<BR><BR>解决办法：<BR>如果存在AD，选择开始-&gt;程序-&gt;管理工具-&gt;Active Directory用户和计算机。为IWAM账号设置密码。<BR>运行c:\Inetpub\AdminScripts&gt;adsutil SET w3svc/WAMUserPass +密码 同步IIS metabase数据库密码<BR>运行cscript c:\inetpub\adminscripts\synciwam.vbs -v 同步IWAM账号在COM+应用程序中的密码<BR><BR><BR>问题8：MIME设置问题导致某些类型文件无法下载（以ISO为例）<BR><BR>症状举例：<BR>HTTP 错误 404 - 文件或目录未找到。<BR><BR>原因分析：<BR>IIS6.0取消了对某些MIME类型的支持，例如ISO，致使客户端下载出错。<BR><BR>解决方法：<BR>在IIS中 属性-&gt;HTTP头-&gt;MIME类型-&gt;新建。在随后的对话框中，扩展名填入.ISO，MIME类型是application。<BR><BR><BR>另外，防火墙阻止，ODBC配置错误，Web服务器性能限制，线程限制等因素也是造成IIS服务器无法访问的可能原因，这里就不再一一馈述了。希望此帖能解决大家的大部分问题：）<BR><img src ="http://www.cnitblog.com/yhf119/aggbug/6768.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yhf119/" target="_blank">杨</a> 2006-02-21 10:08 <a href="http://www.cnitblog.com/yhf119/archive/2006/02/21/6768.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>