javascript技巧

转自:http://topic.csdn.net/u/20080527/10/7f580777-1a3d-44fc-8806-55f9d79d0c65.html

 

(一).确认删除用法:
  1. BtnDel.Attributes.Add(“onclick”,”return confirm(‘”+”确认删除 “+”‘)”);
  2. linktempDelete.Attributes[“onclick”]=”javascript:return  confirm(‘”+”确认删除 “+”‘);”;
  3. private void grdProject_ItemDataBound(object sender, DataGridItemEventArgs e)
  4.
  {
if ((e.Item.ItemType == ListItemType.Item) | (e.Item.ItemType == ListItemType.AlternatingItem))
{
  // 刪除按鈕上的提示部分
  e.Item.Cells[10].Attributes.Add(“onclick”, “return confirm(‘确定删除吗?’);”);

  }
  5.
    <script language=”JavaScript” type=”text/JavaScript”>
function delete_y(e)
        {
    if(event.srcElement.outerText == “删除”)
        event.returnValue=confirm(“确定删除 “);
}
document.onclick=delete_y;
    </script>

(二).跨语言字符串替换
    System.Text.RegularExpressions.Regex.Replace(str1,@” <{1}[^ <>]*>{1}”,””).Replace(“&nbsp;”,””).Replace(“&#092;”,”\\”).Replace(“&#045;”,”-“).Replace(“&amp;”,”&”).Replace(“&lt;”,” <“).Replace(“&gt;”,”>”).Replace(“br”,”\n”);

(三).关闭窗体
  1.
      this.btnClose.Attributes.Add(“onclick”,  “window.close();return false;”);
  2.关闭本窗体间跳转到另一个页面
      this.HyperLink1.NavigateUrl = “javascript:onclick=window.opener.location.assign
        (‘” + “index.aspx”+ ” &Func=Edit&AutoID=” + intAutoid + ‘);window.close();”;
  3.关闭父窗体:
      <INPUT type=”reset” value=’ <%=this._Cancel%>’ onclick=”window.parent.close()”  Class=”Button”>

  4.关闭本弹出窗体,并刷新父页面

      this.Response.Write(” <script language=’javascript’>window.opener.location.reload();window.close(); </script>”);

(四).Web MessageBox 
  1.
      Response.Write(” <script language=javascript> window.alert(‘保存成功1’); </script>”);
  2.
      Response.Write(” <script>alert(‘”+”保存成功!”+”‘); </script>”);
  3.
      this.Page.RegisterStartupScript(“ChiName”,” <script language=’javascript’>alert(‘” + “保存成功!” + “‘) </script>”);

(五).DataGrid中加CheckBox控件模板列.
  请看:  http://blog.csdn.net/chengking/archive/2005/10/08/497520.aspx

(六). window.open() 方法
语法:window.open(pageurl,name,parameters);
window对象的open()方法用于创建一个新的窗口实例,新创建的窗口的外观由参数:parameters指定。新窗口中打开的文档由参数:        pageurl指定。系统能够根据参数:name确定的名称访问该窗口。

        下表为parameters参数表:
        参数          衩始值          说明
        alwaysLowered yes/no 指定窗口隐藏在所有窗口之下。
        alwaysRaised yes/no 指定窗口浮在所有窗口之上。
        dependent yes/no 指定打开的窗口为父窗口的一个了窗口。并随父窗口的关闭而关闭。
        directions yes/no 指定Navigator 2和3的目录栏是否在新窗口中可见。
        height pixel value 设定新窗口的像素高度。
        hotkeys yes/no 在没有菜单栏的新窗口设置安全退出热键。
        innerHeight pixel value 设置新窗口中文档的像素高度。
        innerWidth pixel value 设置新窗口中文档的像素宽度。
        location yes/ no 指明位置栏在新窗口中是否可见。
        menubar yes /no 指明菜单栏在新窗口中是否可见。
        outerHeight pixel value 设定窗口(包括装饰边框)的像素高度。
        outerWidth pixel value 设定窗口(包括装饰边框)的像素宽度。
        resizable yes /no 指明新窗口是否可以调整。
        screenX pixel value 设定新窗口离屏幕边界的像素长度。
        screenY pixel value 设定新窗口离屏幕上边界的像素长度。
        scrollbars yes /no 指明滚动栏在新窗口中是否可见。
        titlebar yes /no 指明菜单题目栏在新窗口是否可见。
        toolbar yes /no 指明工具栏在新窗口中是否可见。
        Width pixel value 设定窗口的像素宽度。
        z-look yes /no 在文档中包含各个 <pplet>标签的数组。
        fullscreen yes / no 打开的窗体是否进行全屏显示
        left pixel value 设定新窗口距屏幕左方的距离
        top pixel value 设定新窗口距屏幕上方的距离
 
      例子:
        <html>
          <head>
              <title>window.open函数 </title>
          </head>
          <body>
              <script language=”javascript”>
                  <!–
                window.open(“”,”name1″,”width=100,height=200,toolbar=no,scrollbars=no,menubar=no,screenX=100,screenY=100″);
                    //–>
              </script>
          </body>
        </html>

(七).location对象   
    href 整个URL字符串.
    protocol 含有URL第一部分的字符串,如http:
    host 包含有URL中主机名:端口号部分的字符串.如//www.cenpok.net/server/
    hostname 包含URL中主机名的字符串.如http://www.cenpok.net
    port 包含URL中可能存在的端口号字符串.
    pathname URL中”/”以后的部分.如~list/index.htm
    hash “#”号(CGI参数)之后的字符串.
    search ” “号(CGI参数)之后的字符串.

(八).按键捕捉
  1.Ctrl+Enter按键捕捉方法
    <body onkeydown=”doKeyDown()”>
    <script language=”JavaScript”>
    <!–
    function doKeyDown()
    {
        if (event.ctrlKey && event.keyCode == 13)
        {
          alert(“You pressed the Ctrl + Enter”)
        }
    }
    //–>
    </script>
    </body>
  2.Alt加快捷键: Alt+A
    <button accessKey=A title=”Alt+A” onclick=”alert(‘Button clicked!’)”>Alt+A </button>
(九).控制输入,非法字符不能输入到TextBox.
    <asp:textbox class=”Text”
        onkeypress=”if (event.keyCode < 48 || event.keyCode >57) event.returnValue = false;”
id=”txtY_Revenue” style=”TEXT-ALIGN: right” runat=”server” Width=”90%” MaxLength=”12″>
    </asp:textbox>
    说明: 此方法控制TextBox只收数字:0~9 , 也自可以定义其它可输入字符,如改成: 65~123,只允许输入: a~z和A~Z 等.

[以下为收藏]

1>屏蔽功能类

1.1 屏蔽键盘所有键
<script language=”javascript”>
<!–
function document.onkeydown(){
  event.keyCode = 0;
  event.returnvalue = false;
}
–>
</script>

1.2 屏蔽鼠标右键

在body标签里加上oncontextmenu=self.event.returnvalue=false

或者

<script language=”javascript”>
<!–
function document.oncontextmenu()
{
  return false;
}
–>
</script>

function nocontextmenu()
{
    if(document.all) {
        event.cancelBubble=true;
        event.returnvalue=false;
        return false;
    }
}

或者

<body onmousedown=”rclick()” oncontextmenu= “nocontextmenu()”>

<script language=”javascript”>
<!–
function rclick()
{
    if(document.all) {
        if (event.button == 2){
            event.returnvalue=false;
        }
    }
}
–>
</script>

1.3 屏蔽 Ctrl+N、Shift+F10、F5刷新、退格键

<script language=”javascript”>
<!–
  //屏蔽鼠标右键、Ctrl+N、Shift+F10、F5刷新、退格键
function window.onhelp(){return false} //屏蔽F1帮助
//function KeyDown(){ 注:本文为引用,应用时发现此句无法实现,经调试采用下面语句代替,如此句可以应用请知道的人指点下,谢谢

function document.onkeydown() {
  if ((window.event.altKey)&&
      ((window.event.keyCode==37)||  //屏蔽 Alt+ 方向键 ←
      (window.event.keyCode==39))){  //屏蔽 Alt+ 方向键 →
    alert(“不准你使用ALT+方向键前进或后退网页!”);
    event.returnvalue=false;
    }

    /* 注:这还不是真正地屏蔽 Alt+ 方向键,
    因为 Alt+ 方向键弹出警告框时,按住 Alt 键不放,
    用鼠标点掉警告框,这种屏蔽方法就失效了。以后若
    有哪位高手有真正屏蔽 Alt 键的方法,请告知。*/

  if ((event.keyCode == 8) &&
      (event.srcElement.type != “text” &&
      event.srcElement.type != “textarea” &&
      event.srcElement.type != “password”) ||          //屏蔽退格删除键 
      (event.keyCode==116)||                            //屏蔽 F5 刷新键
      (event.ctrlKey && event.keyCode==82)){            //Ctrl + R
    event.keyCode=0;
    event.returnvalue=false;
    }
  if ((event.ctrlKey)&&(event.keyCode==78))  //屏蔽 Ctrl+n
    event.returnvalue=false;
  if ((event.shiftKey)&&(event.keyCode==121)) //屏蔽 shift+F10
    event.returnvalue=false;
  if (window.event.srcElement.tagName == “A” && window.event.shiftKey)
      window.event.returnvalue = false;  //屏蔽 shift 加鼠标左键新开一网页
  if ((window.event.altKey)&&(window.event.keyCode==115)){ //屏蔽Alt+F4
      window.showModelessDialog(“about:blank”,””,”dialogWidth:1px;dialogheight:1px”);
      return false;}
  }
/* 另外可以用 window.open 的方法屏蔽 IE 的所有菜单
第一种方法:
  window.open(“你的.htm”, “”,”toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=yes,status=no,top=0,left=0″)
第二种方法是打开一个全屏的页面:
  window.open(“你的.asp”, “”, “fullscreen=yes”)
*/
//–>
</script>

Cuyahoga添加模块

Cuyahoga

国外的开源CMS一般都是基于模块设计的 ,好处是可以随意定制自己的页面和模块,这样在以后的应用中就能够灵活的满足变化的功能需求. 一个模块齐全的CMS如DNN , Rainbow就可以快速搭建符合需求的系统.

下面就来介绍如何为Cuyahoga这个著名的开源网站框架加入具有后台管理的公告模块.可以参考这篇如何在Cuyahoga中新增一个简单的功能模块了解基础的步骤.

为Cuyahoga开发自定义模块时,你可以选择任何数据访问策略.然而Cuyahoga本身是使用NHibernate作为数据持久层,可以做到支持多数据库. 采用Castle.Windsor进行依赖注入,降低模块之间的耦合. 我们的数据访问层也将用NHibernate实现.

最终项目的目录结构如下:

主要步骤如下
1 .创建一个Sql文件(Install.sql)用来安装数据表及添加模块的相关信息 , 该sql文件会在安装模块时,由Cuyahoga自动执行.也可以手工执行进行安装.

install.sql
<!–<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
–>IF NOT EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N[cm_Announcements]AND OBJECTPROPERTY(id, NIsUserTable= 1)
 
BEGIN
CREATE TABLE [cm_Announcements] (
    
[AnnouncementsID] [int] IDENTITY (1,1)NOT NULL ,
    
[sectionid] [int] NOT NULL ,
    
[createdby] [nvarchar] (100NULL ,//公告作者
    
[Title] [nvarchar] (150NULL ,//公告标题
    inserttimestamp 
datetime DEFAULT current_timestamp NOT NULL,
    updatetimestamp 
datetime DEFAULT current_timestamp NOT NULL,
    
    
CONSTRAINT [PK_cm_Announcements] PRIMARY KEY  NONCLUSTERED 
    (
        
[AnnouncementsID]
    ),
    
CONSTRAINT [FK_cm_Announcements_cm_Modules] FOREIGN KEY 
    (sectionid) 
REFERENCES cuyahoga_section (sectionid)
)
END
GO
/*加入模块信息*/
INSERT INTO cuyahoga_moduletype ([name], assemblyname, classname, path, editpath, inserttimestamp, updatetimestamp) VALUES 
(
AnnouncementsCuyahoga.Modules.AnnouncementsCuyahoga.Modules.Announcements.AnnouncementsModule
Modules/Announcements/Announcements.ascxModules/Announcements/EditAnnouncements.aspxcurrent_timestampcurrent_timestamp)
GO
/*加入模块版本信息*/
INSERT INTO cuyahoga_version (assembly, major, minor, patch) VALUES (Cuyahoga.Modules.Announcements150);
go

2.创建域模型 在本例中是实体类

Announcement.cs
<!–<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
–>using System;
using Cuyahoga.Core.Domain;

namespace Cuyahoga.Modules.Announcements.Domain
{
    public class Announcement
    {
        private 
int _id;
        private string _title;
        private string _content;
        private 
DateTime _expiredate;
        private Section _section;
        private 
User _createdBy;
        private 
DateTime _updateTimestamp;

        /// <summary>
        
/// Property Id (int)
        
/// </summary>
        
public int Id
        {
            get { 
return this._id; }
            
set { this._id = value; }
        }
        
/// <summary>
        
/// Property Title (string)
        
/// </summary>
        
public string Title
        {
            get { 
return this._title; }
            
set { this._title = value; }
        }
        
/// <summary>
        
/// Property Section (Section)
        
/// </summary>
        
public Section Section
        {
            get { 
return this._section; }
            
set { this._section = value; }
        }
        
/// <summary>
        
/// Property CreatedBy (User)
        
/// </summary>
        
public User CreatedBy
        {
            get { 
return this._createdBy; }
            
set { this._createdBy = value; }
        }
        
/// <summary>
        
/// Property UpdateTimestamp (DateTime)
        
/// </summary>
        
public DateTime UpdateTimestamp
        {
            get { 
return this._updateTimestamp; }
            
set { this._updateTimestamp = value; }
        }
        
public Announcement()
        {
            this._id 
= 1;
        }
    }
}

3.创建映射文件

Announcement.hbm.xml
<!–<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
–>xml version=”1.0″ encoding=”utf-8″  >
<hibernate-mapping xmlns=”urn:nhibernate-mapping-2.0″>
  
<class name=”Cuyahoga.Modules.Announcements.Domain.Announcement, Cuyahoga.Modules.Announcements” table=”cm_Announcements”>
    
<id name=”Id” column=”Announcementsid” type=”Int32″ unsaved-value=”-1″>
      
<generator class=”native”>
        
<param name=”sequence”>cm_Announcements_Announcementsid_seq</param>
      
</generator>
    
</id>
    
<timestamp name=”UpdateTimestamp” column=”updatetimestamp” />
    
<property name=”Title” column=”title” type=”String” length=”150″ />
    
<many-to-one name=”Section” class=”Cuyahoga.Core.Domain.Section, Cuyahoga.Core” column=”sectionid” not-null=”true” />
    
<many-to-one name=”CreatedBy” class=”Cuyahoga.Core.Domain.User, Cuyahoga.Core” column=”createdby” not-null=”true” />
  
</class>
</hibernate-mapping>

4.创建公告模块的核心控制类

AnnouncementsModule.cs
<!–<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
–>using System;
using System.Collections;
using System.Xml;
using System.Xml.XPath;
using System.Net;
using System.Web;
using System.Text;
using System.IO;
using System.Threading;

using NHibernate;
using Castle.Services.Transaction;
using Castle.Facilities.NHibernateIntegration;

using log4net;

using Cuyahoga.Core;
using Cuyahoga.Core.Domain;
using Cuyahoga.Core.Service;
using Cuyahoga.Core.Util;
using Cuyahoga.Web.Util;
using Cuyahoga.Web.Components;
using Cuyahoga.Modules.Announcements.Domain;

namespace Cuyahoga.Modules.Announcements
{
    
//采用Facilities管理事务
    [Transactional]
    
public class AnnouncementsModule : ModuleBase, INHibernateModule
    {
        
private static readonly ILog log = LogManager.GetLogger(typeof(AnnouncementsModule));
        
private int _cacheDuration;
        
private ISessionManager _sessionManager;

        //该模块需要用到NHibernate session manager提供的服务 进行依赖注入
        public AnnouncementsModule(ISessionManager sessionManager)
        {
            
this._sessionManager = sessionManager;
        }

        public override void ReadSectionSettings()
        {
            
base.ReadSectionSettings();
            
// Set dynamic module settings
            this._cacheDuration = Convert.ToInt32(base.Section.Settings[CACHE_DURATION]);
        }

        ///不创建子事务
        [Transaction(TransactionMode.RequiresNew)]
        
public virtual IList GetAllAnnouncements()
        {
            ISession session 
= this._sessionManager.OpenSession();
            
string hql = from Announcement f where f.Section.Id = :sectionId;
            IQuery q 
= session.CreateQuery(hql);
            q.SetInt32(
sectionIdbase.Section.Id);
            
return q.List();
        }

        [Transaction(TransactionMode.RequiresNew)]
        public virtual Announcement GetAnnouncementsById(int AnnouncementsID)
        {
            ISession session 
= this._sessionManager.OpenSession();
            
return (Announcement)session.Load(typeof(Announcement), AnnouncementsID);
        }

        [Transaction(TransactionMode.RequiresNew)]
        public virtual void SaveAnnouncement(Announcement announcements)
        {
            ISession session 
= this._sessionManager.OpenSession();
            session.SaveOrUpdate(announcements);
        }

        [Transaction(TransactionMode.RequiresNew)]
        public virtual void DeleteAnnouncements(Announcement announcements)
        {
            ISession session 
= this._sessionManager.OpenSession();
            session.Delete(announcements);
        }
    }
}

5.创建用于前台显示的用户控件 用来显示公告的标题 作者和发布时间.

Announcements.ascx
<!–<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
–><%@ Control Language=C# AutoEventWireup=true Codebehind=Announcements.ascx.cs
    Inherits
=Cuyahoga.Modules.Announcements.Web.Announcements %>
<asp:repeater id=rptAnnouncementItems runat=server enableviewstate=False>
    
<itemtemplate>
            
<div class=genericdetails style=width:100%>
            
<marquee  direction=left >
                
<asp:label id=lblTitle runat=server><%# DataBinder.Eval(Container.DataItem, Title)%></asp:label>
                
<asp:label id=lblAuthor runat=server>作者:<%# DataBinder.Eval(Container.DataItem, CreatedBy.FullName)%></asp:label>
                
<asp:label id=lblTime runat=server>发布时间:<%# DataBinder.Eval(Container.DataItem, UpdateTimestamp)%></asp:label>
            
</marquee>
            
</div>
    
</itemtemplate>
</asp:repeater>

Announcements.ascx.cs
<!–<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
–>using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using Cuyahoga.Core.Util;
using Cuyahoga.Web.UI;
using Cuyahoga.Modules.Announcements.Domain;

namespace Cuyahoga.Modules.Announcements.Web
{
    
public partial class Announcements : BaseModuleControl
    {
        
private AnnouncementsModule _module;
        
protected void Page_Load(object sender, EventArgs e)
        {
            
if (!this.IsPostBack && !base.HasCachedOutput)
            {
                
this._module = base.Module as AnnouncementsModule;
                
this.rptAnnouncementItems.DataSource = this._module.GetAllAnnouncements();
                
this.rptAnnouncementItems.DataBind();
            }
        }
    }
}

6.创建公告管理的列表页面

EditAnnouncements.aspx
<!–<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
–><%@ Page Language=C# AutoEventWireup=true Codebehind=EditAnnouncements.aspx.cs
    Inherits
=Cuyahoga.Modules.Announcements.Web.EditAnnouncements %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
    
<title>公告管理页面</title>
</head>
<body>
    
<form id=”Form1″ method=”post” runat=”server”>
        
<div id=”moduleadminpane”>
            
<h1>
                公告管理
</h1>
            
<table class=”tbl”>
                
<asp:Repeater ID=”rptAnnouncements” runat=”server” OnItemDataBound=”rptFiles_ItemDataBound”>
                    
<HeaderTemplate>
                        
<tr>
                            
<th>
                                公告标题
</th>
                            
<th>
                                作者
</th>
                            
<th>
                                发布日期
</th>
                            
<th>
                            
</th>
                        
</tr>
                    
</HeaderTemplate>
                    
<ItemTemplate>
                        
<tr>
                            
<td>
                                
<%# DataBinder.Eval(Container.DataItem, Title%>
                            
</td>
                            
<td>
                                
<%# DataBinder.Eval(Container.DataItem, CreatedBy.FullName)%>
                            
</td>
                            
<td>
                                
<asp:Literal ID=”litDateModified” runat=”server”></asp:Literal></td>
                            
<td>
                                
<asp:HyperLink ID=”hplEdit” runat=”server”>修改</asp:HyperLink>
                            
</td>
                        
</tr>
                    
</ItemTemplate>
                
</asp:Repeater>
            
</table>
            
<br />
            
<input id=”btnNew” type=”button” value=”新的公告” runat=”server” name=”btnNew”/>
        
</div>
    
</co

建立Silverlight2.0控件(Usercontrol)

Silverlight 2.0有一个非常重要的部分,就是控件技术的出现,透过可自行定义开发的控件建立机制,Silverlight ASP.NET一样,可以自行定义可重用的 UserControl,这对于开发人员有着相当重要的意义,这表示对象化的设计、ReUse与大量的开发开始变的可能。

< xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” />

有这些作为基础,我们才有可能真正透过Sivlerlight 2.0建立中大型的应用程序或是RIA,也才有可能确保投资可以延续并且在团队开发当中累积资源。

这么重要的机制,当然要给他试用一下,上图是我尝试建立的traffic light控件,模拟一个红绿灯,一样具有属性、事件、方法……可以跟外部的程序互动,画面中的ButtonTextBox则是Silverlight 2.0当中本来就有的控件,通过.NET Code的开发方式,你可以用C#或是VB,确实比过去1.0时代用JavaScriptAJAX方便很多。

在该控件在被使用者点选之后,会触发一个Click事件,这个事件是我们自己建立出来的,我们可以在这个事件当中改变TextBox内的值(你试用看看就知道)。当然,我们也可以在其他控件(例如按钮)当中来改变灯号(通过traffic light控件的属性),总而言之,这就是一个标准的控件啦。

您可以点选[这里]测试一下这个控件,关于程序代码的说明我会在七月的Run!PC当中介绍,如果您需要Source Code,请私下偷偷Mail给我。

如何实现Asp与Asp.Net共享Session

微软.net中,session的存储机制已经与asp的存储机制不一样,虽然可以在同一个iis下同时运行asp与aspx,但是它们之间不能传递session。
之前大批系统应用到了asp,在升级过程中,如果完全抛弃asp来重写,一来工作量太大,二来以前的成果不能保存下来。

所以微软提出了一个session共享的解决方案,只是此文档光说明原理,并没有说具体的操作步骤,由此,我撰文描述过程。

简单说明原理,asp与asp.net之间的session统一存储在数据库中来实现共享

1、创建数据表
打开sql server查询分析器,运行以下脚本来创建数据表,数据表名为sessionstate
if exists (select * from sysobjects where id = object_id(n'[dbo].[sessionstate]’) and objectproperty(id, n’isusertable’) = 1)
drop table [dbo].[sessionstate]
go

create table [dbo].[sessionstate] (
[id] uniqueidentifier not null ,
[data] [image] not null ,
[last_accessed] [datetime] not null
) on [primary] textimage_on [primary]
go

alter table [dbo].[sessionstate] with nocheck add
constraint [pk_sessionstate] primary key nonclustered
(
[id]
) on [primary]
go

2、下载以下文件 session.rar

将文件解压后,将产生4个文件,分别作如下操作。
复制 global.asa 到系统根目录下,并打开文件,修改application(“sessiondsn”) 为合适的数据库链接字符串,如果系统本身已经有了global.asa,则在此文件中添加如下application:
application(“sessiondsn”) = “initial catalog=sqlservername;persist security info=false;user id=sa;password=****;packet size=4096”
在系统的 web.config 文件中,添加此项
<add key=”sessiondsn” value=”data source=sqlservername;initial catalog=sessiondemodb;persist security info=false;user id=sessiondemodbuser;password=****;packet size=4096″ />
并将其值修改为合适的数据库链接。
将另外两个dll文件复制到系统目录下(或其他合适目录)

3、关闭iis中asp的session选项
打开iis,选择站点,依次选择属性 -> 主目录 -> 配置 -> 应用程序选项,将启用会话状况前的复选勾去除。如下图:
screen.width-350)this.width=screen.width-350″ border=0>

4、安装sessionutility.dll
首先找到 gacutil.exe 文件,一般情况下在 microsoft visual studio .net 2003\sdk\v1.1\bin 目录下
在命令提示符窗口中,执行 gacutil /i sessionutility.dll,(如果执行失败,请将这两个文件的路径都写全了)

5、注册sessionutility.dll为com对象
同样,要找到 regasm.exe 文件,一般情况下在 winnt\microsoft.net\framework\v1.1.4322 目录下
在命令提示符窗口中,执行 regasm.exe sessionutility.dll /tlb:sessionutility.tlb,(如果执行失败,请将这两个文件的路径都写全了)
这样就会产生出一个tlb文件,可当做普通的com组件来调用。

6、注册sessionmanager.dll
这个很简单了,在命令提示符窗口中,执行regsvr32 sessionmanager.dll

7、如果是ntfs格式的系统,请找到 sessionmgr.dll,右键点击,属性,将iusr_<machine_name>权限设置为可读和可执行。

至此,我们已经可以实现了asp与asp.net之间session共享了,那么怎么去用

在asp中,我们要如下使用:
页面开始端
dim session
set session = server.createobject(“sessionmgr.session2”)
session(“userid”) = …



页面结束端
set session = nothing ‘记得一定要释放哦

而在asp.net中,我们要如下使用:
首先,我们要添加对sessionutility的引用
然后,编码时,原来是这样的继承 public class webform1 : system.web.ui.page,修改为public class webform1 : msdn.sessionpage
这样在编码过程中就可以使用session(“userid”)这样的形式了。

注意:虽然session实现了共享,但是session的使用语法,相对于.net中新增的部分,就没有实现,毕竟要照顾asp
譬如session.remove,就不能用了。

 

MS-SQL2005以上的版本解决Syscolumn表中数据不能修改

例如:

在MSSQL2000里面可以获取到相应的数据

获取TrainManage表中的TrainId字段

String.Format(“Select name From Syscolumns Where id = (Select id From sysobjects Where name='{0}’) And autoval Is Not Null”, _TableName)

但是在MSSQL2005以上的版本没有该条记录的数据

解决方案:

String.Format(“Select top 1 name From Syscolumns Where id = (Select id From sysobjects Where name='{0}’) And xtype = 127 “, _TableName)

为什么要这么做呢,而不通过获取某个表的字段名字就行呢。

因为这个是common文件,其他的文件也要调用这个sql语句了

,考虑到这点。所以现在只想到这个了,其他的还没有想到,如果有更好的,希望您能分享一下,如果有错误请批评指出。

ASP.NET2.0页面框架的几处变化

作者:http://blog.joycode.com/liuhuimiao/

  1. 新增的页面事件
    在ASP.NET 2.0中,一个ASP.NET页面的生命周期主要为(红色字体表示ASP.NET 2.0新增加的阶段页面事件):客户端请求页面—》预初始化(OnPreInit)—》初始化(OnInit)—》完成初始化(OnInitComplete)—》载入ViewState(LoadViewState)—》处理回送数据(IPostBackDataHandler)—》Page_OnPreLoad—》Page_OnLoad—》回发更改通知(RaisePostDataChangedEvent)—》处理回发事件(RaisePostBackEvent)—》Page_OnLoadComplete—》预呈现(OnPreRender)—》完成预呈现(OnPreRenderComplete)—》保存ControlState(SaveControlState)—》保存ViewState(SaveViewState)—》呈现(Render)—》Page_UnLoad。

    • OnPreInit:在初始化页面OnInit事件前触发。在这个阶段里,可以进行定义站点主题(Theme)或加载站点个性化所需要的数据信息等操作。
    • OnInitComplete:完成初始化页面OnInit事件后触发。
    • OnPreLoad:在加载页面OnLoad事件前触发。
    • OnLoadComplete:完成页面加载OnLoad事件后触发。
    • OnPreRenderComplete:在完成预呈现OnPreRender事件后触发。这是完成页面呈现的最后一道关卡,在此之后,页面将无法再进行任何呈现上的改动。
    • SaveControlState:保存控件状态ControlState。ControlState是ASP.NET2.0控件新增的一个属性,类似ViewState作用,但它们区别在于ControlState用于保存更加重要的控件状态信息,以保证在禁用ViewState的情况下还可以对控件状态进行读写操作。
  2. 增加对页面Header的控制:
    System.Web.UI.Page类新增加了Header属性,用于对HTML页面头区域里数据的操作。通过对Header属性的跟踪,可以发现,Header属性保存着一个实现IPageHeader接口的对象(该对象有LinkedStyleSheets、Metadata、StyleSheet和Title四个属性),实际上正是通过这个对象实现对HTML页面头区域里数据的操作的。例如:
    <script runat=server>
    void Page_Load(object sender, System.EventArgs e)
    {
    this.Header.Metadata.Add(author, brooks);
    }
    </script>

    其运行结果为:
    <html>
    <head> <title>Untitled Page</title>
    <meta name=”author” content=”brooks” />
    </head>
  3. 定义表单中的默认按钮:
    在ASP.NET1.0中,我就为了设置表单中的默认按钮而一筹莫展。幸好ASP.NET2.0把这个功能补上了,现在可以非常方便的设置表单中的默认按钮了。
    <%@ page language=C# %>
    <script runat=”server”>
    void Button1_Click(object sender, System.EventArgs e)
    {
    this.LB_Message.Text = You clicked button1;
    }
    </script>
    <html>
    <head runat=”server”>
    <title>Untitled Page</title>
    </head>
    <body>
    <form runat=”server” defaultbutton=”Button1″>
    <asp:textbox id=”Textbox1″ runat=”server”></asp:textbox>
    <asp:button id=”Button1″ runat=”server” text=”Button” onclick=”Button1_Click” />
    <asp:label id=”LB_Message” runat=”server”></asp:label>
    </form>
    </body>
    </html>
  4. 设置焦点
    现在假设为TextBox1控件设置焦点,在ASP.NET 2.0中可以这样实现:
    this.Textbox1.Focus(); this.SetFocus(this.Textbox1); 即可为TextBox1控件设置焦点。
    如果打算也为表单设置个默认焦点控件,让光标默认停留在TextBox1上:
    <form runat=”server” defaultfocus=”TextBox1″>
  5. 跨页面数据发送
    如果你需要多个页面发送数据到同一个表单程序进行处理,或者数据在多个页面之间传输处理的话,你就可以使用ASP.NET 2.0这个新特性。例如,我打算把Default.aspx页里TextBox1里的文本数据发送到Default2.aspx页面进行处理:
    Default.aspx页:
    <%@ Page Language=C# %>
    <script runat=”server”>
    void Button2_Click(object sender, EventArgs e)
    {
    Label1.Text
    = Hi, + TextBox1.Text + . This is Default.aspx;
    }
    </script>

    <html xmlns=”http://www.w3.org/1999/xhtml” >
    <head runat=”server”>
    <title>Untitled Page</title>
    </head>
    <body>
    <form id=”form1″ runat=”server”>
    <asp:TextBox ID=”TextBox1″ Runat=”server”></asp:TextBox>
    <asp:Button ID=”Button1″ Runat=”server” Text=”PostToAnotherPage” PostBackUrl=”~/Default2.aspx” />
    <asp:Button ID=”Button2″ Runat=”server” Text=”PostToSelf” OnClick=”Button2_Click” />
    <br />
    <asp:Label ID=”Label1″ Runat=”server” Text=”Label”></asp:Label>
    </form>
    </body>
    </html>
    Default2.aspx页:
    <%@ Page Language=C# %>
    <script runat=”server”>
    void Page_Load(object sender, System.EventArgs e)
    {
    TextBox textBox1
    = (TextBox)PreviousPage.FindControl(TextBox1);
    this.Label1.Text = Hi, + textBox1.Text + . This is Default2.aspx!;
    }
    </script>
    <html xmlns=”http://www.w3.org/1999/xhtml” >
    <head runat=”server”>
    <title>Untitled Page</title>
    </head>
    <body>
    <form id=”form1″ runat=”server”>
    <asp:label id=”Label1″ runat=”server”></asp:label>
    </form>
    </body>
    </html>

打发时光的102个好网站

1,看看自己具有哪个大明星的脸型 <a href="http://www.play-analogia.com/cgi-bin/index/" target=_blank><font color=#3b5998>http://www.play-analogia.com/cgi-bin/index/</font></a> <br><br>  2,超有意思的Flash网站,虚拟办公 <a href="http://agencynet.com/" target=_blank><font color=#3b5998>http://agencynet.com</font></a><br><br>  3,亲自动手给美女画纹身 <a href="http://www.crustydemons.co.uk/UK/tattoo_parlour/index.html" target=_blank><font color=#3b5998>http://www.crustydemons.co.uk/UK/tattoo_parlour/index.html</font></a><br><br>  4,输入文字就发出声音! <a href="http://www.putonghuaonline.com/" target=_blank><font color=#3b5998>http://www.putonghuaonline.com</font></a><br><br>  只支持繁体中文,同时也是学习普通话和粤语的好地方<br><br>  5,在线做个通缉令 <a href="http://www.glassgiant.com/wanted/" target=_blank><font color=#3b5998>http://www.glassgiant.com/wanted/</font></a><br><br>  6,制作属于自己的卡通大头像吧 <a href="http://cartoon.msn.com.cn/" target=_blank><font color=#3b5998>http://cartoon.msn.com.cn</font></a><br><br>  7,在你的照片上添加有趣对话 <a href="http://www.bubblesnaps.com/" target=_blank><font color=#3b5998>http://www.bubblesnaps.com</font></a><br><br>  8,这个网站提供各种有趣的在线拼图 <a href="http://www.thebroth.com/" target=_blank><font color=#3b5998>http://www.thebroth.com</font></a><br><br>  9,很逼真!模仿XP系统操作的网站 <a href="http://www.kingnare.com/" target=_blank><font color=#3b5998>http://www.kingnare.com</font></a><br><br>  10,原来制作带阴影的LOGO如此容易 <a href="http://msig.info/web2.php" target=_blank><font color=#3b5998>http://msig.info/web2.php</font></a><br><br>  11,教你打领带 <a href="http://www.tieknot.com/dalingdai.html" target=_blank><font color=#3b5998>http://www.tieknot.com/dalingdai.html</font></a><br><br>  12,系鞋带的N种方法 <a href="http://www.fieggen.com/shoelace/lacingmethods.htm#2trillion" target=_blank><font color=#3b5998>http://www.fieggen.com/shoelace/lacingmethods.htm#2trillion</font></a><br><br>  13,咱也弄个自己的徽章玩玩 <a href="http://www.says-it.com/seal/index.php" target=_blank><font color=#3b5998>http://www.says-it.com/seal/index.php</font></a><br><br>  14,在线素描 <a href="http://flashface.ctapt.de/" target=_blank><font color=#3b5998>http://flashface.ctapt.de</font></a><br><br>  15,各种动画图标制做 <a href="http://ajaxload.info/" target=_blank><font color=#3b5998>http://ajaxload.info</font></a><br><br>  16,各种字体图片制做 <a href="http://cooltext.com/" target=_blank><font color=#3b5998>http://cooltext.com</font></a><br><br>  17,<a href="http://www.pollyglotto.com/index8.php" target=_blank><font color=#3b5998>http://www.pollyglotto.com/index8.php</font></a><br><br>  超牛的语音翻译,输入文字里面的人自动给你以语音的形式翻译出来,有趣的是他眼睛跟你你鼠标转,遗憾的是不是免费的!<br><br>  18,你今天印书了么?免费将你的博客翻印成书 <a href="http://www.mrprint.cn/ UN=f1208b59454a9a744055&amp;ShowType=0" target=_blank><font color=#3b5998>http://www.mrprint.cn/ UN=f1208b59454a9a744055&amp;ShowType=0</font></a><br><br>  19,做个德国身份证玩玩 <a href="http://onlinewahn.de/generator/" target=_blank><font color=#3b5998>http://onlinewahn.de/generator/</font></a><br><br>  20,自己做个图来让别人拼 <a href="http://www.flash-gear.com/puzzle/" target=_blank><font color=#3b5998>http://www.flash-gear.com/puzzle/</font></a><br><br>  21,在线媒体提取工具 <a href="http://solor.cn/" target=_blank><font color=#3b5998>http://solor.cn</font></a><br><br>  22,DiY网络拼图 <a href="http://www.webpuzzle.cn/" target=_blank><font color=#3b5998>http://www.webpuzzle.cn</font></a><br><br>  23,2G网络硬盘,仿windows操作系统 <a href="http://www1.pc2n.com/" target=_blank><font color=#3b5998>http://www1.pc2n.com</font></a><br><br>  24.在线媒体转换工具 <a href="http://media-convert.com/" target=_blank><font color=#3b5998>http://media-convert.com</font></a><br><br>  它支持大量的文件格式之间的互相转换,包括视频、音频、PPT文档、Word文档、表格文档、图片等等数十种之多。比如你可以把mp3转换成wav,把png转换成gif,把word文件转换成txt文件<br><br>  25.在线保存,分享和交流网页,博客,新闻 <a href="http://www.hinale.com/" target=_blank><font color=#3b5998>http://www.hinale.com</font></a><br><br>  为您的一篇文章嵌入Hinale按钮,更方便用户保存和交流您的文章<br><br>  26.blog 搜索引擎 <a href="http://www.gnoos.com.au/" target=_blank><font color=#3b5998>http://www.gnoos.com.au</font></a><br><br>  27.[ ImageCrop ] <a href="http://www.imagecrop.com/" target=_blank><font color=#3b5998>http://www.imagecrop.com</font></a><br><br>  功能相对简单,它其实是一款为MSN、Yahoo Messager等制作头像的剪裁工具,因此,它的特色在于内置了专用尺寸模板,比如MSN、论坛头像75&#215;75或85&#215;85的尺寸等等。当然也可以自定义大小。<br><br>  28.[ Online Image Editor ] <a href="http://www.online-image-editor.com/" target=_blank><font color=#3b5998>http://www.online-image-editor.com</font></a><br><br>  支持JPG、PNG、GIF及BMP格式的图像,具备可转换颜色模式,添加边框,转换图像格式等功能,内置10个滤镜效果。<br><br>  29.[ GifWorks ]Gif动画处理工具 <a href="http://gifworks.com/" target=_blank><font color=#3b5998>http://gifworks.com</font></a><br><br>  可生成动画效果的文字,不过不支持中文。可编辑的图像格式只有Gif类型,允许上传最大单个文件为400K。具备30多种滤镜效果、3 种优化工具及旋转、剪裁等常用图像编辑功能<br><br>  30.[ Colorcombos ] <a href="http://www.colorcombos.com/" target=_blank><font color=#3b5998>http://www.colorcombos.com</font></a><br><br>  是一个网页配色自动探测工具,你只需输入网站地点,它就会帮你把该网站当前的网页配色方案展示出来,并提供相应的色值<br><br>  31.[ PhotoShow ] <a href="http://www.photoshow.com/" target=_blank><font color=#3b5998>http://www.photoshow.com</font></a><br><br>  是一个新型的图片展示服务,利用Flash技术构建。事实上,也可以把它当作如<br><br>  [ ibloks ] <a href="http://www.wappblog.com/entry/200.html" target=_blank><font color=#3b5998>http://www.wappblog.com/entry/200.html</font></a><br><br>  [ Eyespot ] <a href="http://www.wappblog.com/entry/108.html" target=_blank><font color=#3b5998>http://www.wappblog.com/entry/108.html</font></a><br><br>  等这样的混合工具,它可把图片及音乐混合,做成一段效果非常酷的流媒体。<br><br>  32.[ Imagesquash ] <a href="http://www.imagesquash.com/" target=_blank><font color=#3b5998>http://www.imagesquash.com</font></a><br><br>  又是一个图片转换工具,它可以根据按上传图片大小的百分比进行缩小,可转换图片格式为Jpeg、Gif及PNG,可改变图片质量。<br><br>  33.[ 在线ping你的博客 ] <a href="http://214.5d6d.com/" target=_blank><font color=#0000ff>http://214.5d6d.com/</font></a><br><br>  34.[ iBloks ] 是一个多媒体混合工具,它能把照片及音乐混合成一段视频<br><br>  <a href="http://www.ibloks.com/" target=_blank><font color=#3b5998>http://www.ibloks.com</font></a>  <br><br>  35.[ Web2.0 STYLr ] 是一个web2.0 Logo制作工具<br><br>  <a href="http://web2.0stylr.com/stylr.aspx" target=_blank><font color=#3b5998>http://web2.0stylr.com/stylr.aspx</font></a><br><br>  36.[ Web2.0 Logo Creator ] <a href="http://msig.info/web2.php" target=_blank><font color=#3b5998>http://msig.info/web2.php</font></a><br><br>  是一个专门用来制作web2.0网站logo的在线工具,制作出的logo具备了几个web2.0元素,比如倒影、beta标志等等,在有些地方可能不能打开这个网站,可以去<a href="http://www.cnproxy.com/webproxy.asp" target=_blank><font color=#3b5998>http://www.cnproxy.com/webproxy.asp</font></a>,通过代理打开!!<br><br>  37.爱因斯坦写汉字 <a href="http://www.sbfun.org/einstein/index.php" target=_blank><font color=#3b5998>http://www.sbfun.org/einstein/index.php</font></a><br><br>  38.[ Crusty Demons ] <a href="http://www.crustydemons.co.uk/UK/tattoo_parlour/index.html" target=_blank><font color=#3b5998>http://www.crustydemons.co.uk/UK/tattoo_parlour/index.html</font></a>]<br><br>  是一个在线的纹身视频制作工具,可自定义纹身图案、文字内容和纹身位置,完成后会生成一段视频,并且可下载图片或者发送给朋友<br><br>  39.[ Ponyfish ] <a href="http://www.ponyfish.com/" target=_blank><font color=#3b5998>http://www.ponyfish.com</font></a><br><br>  是一个在线Feed创建工具<br><br>  40.[ SubAdjust-Web ] <a href="http://dev.pdvel.com/subadjust/index.php" target=_blank><font color=#3b5998>http://dev.pdvel.com/subadjust/index.php</font></a><br><br>  是一个用来调整DVD字幕的在线工具,你可以通过<br><br>  [ SubAdjust-Web ] <a href="http://dev.pdvel.com/subadjust/index.php" target=_blank><font color=#3b5998>http://dev.pdvel.com/subadjust/index.php</font></a><br><br>  来调整DIVX字幕的时间,以便使其与DVD视频同步,另外还可以用来在SubRip和MirroDVD字幕两种格式之间互换。<br><br>  41.在线favicon图标制作 <a href="http://tools.dynamicdrive.com/favicon/" target=_blank><font color=#3b5998>http://tools.dynamicdrive.com/favicon/</font></a><br><br>  42.[ converticon.com ] <a href="http://converticon.com/" target=_blank><font color=#3b5998>http://converticon.com</font></a><br><br>  是一个在线ico文件和png文件互相转化工具<br><br>  43.[ krun.ch ] <a href="http://krun.ch/" target=_blank><font color=#3b5998>http://krun.ch</font></a><br><br>  提供了本地文件和网络文件的压缩和解压四种功能,压缩或解压缩后的文件可以下载到本地。另外它提供了zip、rar和gzip压缩文件格式供选择<br><br>  44.[ 在线做个徽章 ] <a href="http://www.says-it.com/seal/index.php" target=_blank><font color=#3b5998>http://www.says-it.com/seal/index.php</font></a><br><br>  45.在这里,你可以在线做个以自己照片做硬币人物的硬币图片,好酷哦!!<br><br>  <a href="http://onlinewahn.de/generator/m-maker.htm" target=_blank><font color=#3b5998>http://onlinewahn.de/generator/m-maker.htm</font></a><br><br>  46.想想自己的照片被外文报纸刊登在头版头条该是多么风光,在这里就可以轻松实现 <a href="http://onlinewahn.de/generator/z-maker.htm" target=_blank><font color=#3b5998>http://onlinewahn.de/generator/z-maker.htm</font></a><br><br>  47.一个在线生成flash菜单的网站,对站长很有帮助. <a href="http://www.hostsun.com/gr/flash_generators.php" target=_blank><font color=#3b5998>http://www.hostsun.com/gr/flash_generators.php</font></a><br><br>  48.对有些做了IP限制的网站,可能无法访问,可以使用这个代理访问. <a href="http://www.cnproxy.com/" target=_blank><font color=#3b5998>http://www.cnproxy.com</font></a><br><br>  49.在线图片处理,网通 <a href="http://www.iephotoshop.com/" target=_blank><font color=#3b5998>http://www.iephotoshop.com</font></a><br><br>   电信 <a href="http://www1.iephotoshop.com/" target=_blank><font color=#3b5998>http://www1.iephotoshop.com</font></a><br><br>  50.你可以制作出很有专业水准的动态logo,有很多的样式供你选择 <a href="http://www.logomaker.cn/" target=_blank><font color=#3b5998>http://www.logomaker.cn</font></a><br><br>  51.Flash头像 <a href="http://www.dookyweb.com/avatars.swf" target=_blank><font color=#3b5998>http://www.dookyweb.com/avatars.swf</font></a><br><br>  52.印象派涂鸦板 <a href="http://jacksonpollock.org/" target=_blank><font color=#3b5998>http://jacksonpollock.org</font></a><br><br>  53.在线网页截屏工具,在浏览器地址栏输入下面的代码就可以了。<br><br>  <a href="http://images.websnapr.com/ url=thw.568idc.com" target=_blank><font color=#3b5998>http://images.websnapr.com/ url=thw.568idc.com</font></a>红色部分换成你想要截的网页的地址<br><br>  54.另外两个好用在线网页截屏工具 <a href="http://www.browsrcamp.com/" target=_blank><font color=#3b5998>http://www.browsrcamp.com/</font></a> 和 <a href="http://snap.otag.cn/screenshot.aspx" target=_blank><font color=#3b5998>http://snap.otag.cn/screenshot.aspx</font></a><br><br>  55.可以突破网吧的下载限制进行下载 <a href="http://thw.568idc.com/serve/xiazai.html" target=_blank><font color=#3b5998>http://thw.568idc.com/serve/xiazai.html</font></a><br><br>  56.跳转FLASH生成工具 <a href="http://www.dfxy.org/tiao/" target=_blank><font color=#3b5998>http://www.dfxy.org/tiao/</font></a><br><br>  57.[krun.ch] <a href="http://krun.ch/" target=_blank><font color=#3b5998>http://krun.ch</font></a><br><br>  是一个在线压缩工具,它提供了本地文件上传压缩和解压、网络文件的压缩和解压四种功能,压缩或解压缩后的文件可以下载到本地或者通过Email发送。另外它提供了zip、rar和gzip压缩文件格式供选择。<br><br>  58.在线生成纯css代码实现的圆角矩形的网站,对网站制作者很有用的东西<br><br>  <a href="http://www.spiffycorners.com/" target=_blank><font color=#3b5998>http://www.spiffycorners.com</font></a><br><br>  59.it" target=_blank&amp;gt;http://pentacom.jp/soft/ex/" target=_blank&amp;gt;http://www.onlinewahn.de/generator/m-maker.htm<br><br>  61.图片仓库:            <br><br>  <a href="http://pic.sdodo.com/" target=_blank><font color=#3b5998>http://pic.sdodo.com/</font></a><a href="http://pic.sdodo.com/" target=_blank><font color=#0000ff>http://pic.sdodo.com/</font></a><br><br>  62.在线FLASH动画制作         <br><br>  <a href="http://www.dfilm.com/index_movie_start.html" target=_blank><font color=#3b5998>http://www.dfilm.com/index_movie_start.html</font></a><br><br>  63.图片生成网页图标          <br><br>  <a href="http://www.chami.com/html-kit/services/favicon/" target=_blank><font color=#3b5998>http://www.chami.com/html-kit/services/favicon/</font></a><br><br>  64.由蝌蚪网络提供的Gmail注册入口   <br><br>  <a href="http://cnc.kedooo.net/gmail/" target=_blank><font color=#3b5998>http://cnc.kedooo.net/gmail/</font></a><br><br>  65.最全的邮件/QQ/MSN/BLOG图片生成器 <br><br>  <a href="http://www.eoool.com/" target=_blank><font color=#3b5998>http://www.eoool.com/</font></a><br><br>  66.收藏夹图标生成器         <br><br>  <a href="http://www.html-kit.com/e/favicon.cgi" target=_blank><font color=#3b5998>http://www.html-kit.com/e/favicon.cgi</font></a><br><br>  67.在线域名LOGO生成         <br><br>  <a href="http://phorum.com.tw/Generator.aspx" target=_blank><font color=#3b5998>http://phorum.com.tw/Generator.aspx</font></a><br><br>  68.免费3D banner在线制做网站    <br><br>  <a href="http://www.3dtextmaker.com/cgi-bin/3dtext.pl" target=_blank><font color=#3b5998>http://www.3dtextmaker.com/cgi-bin/3dtext.pl</font></a><br><br>  69.输入图片就能查看字体      <br><br>  <a href="http://www.my/" target=_blank><font color=#3b5998>http://uptime.netcraft.com/up/</font></a><br><br>  72.查看该域名IP主机下的其他域名  <br><br>  <a href="http://whois.webhosting.info/" target=_blank><font color=#3b5998>http://whois.webhosting.info/</font></a><br><br>  73.生成email图片         <br><br>  <a href="http://www.nhacks.com/email/index.php" target=_blank><font color=#3b5998>http://www.nhacks.com/email/index.php</font></a><br><br>  74.世界网络里面有很多不错的测试  <br><br>  <a href="http://www.linkwan.com/gb/broadmeter" target=_blank><font color=#3b5998>http://www.linkwan.com/gb/broadmeter</font></a><br><br>  75.几个大城市的地图搜索      <br><br>  <a href="http://map.zhongsou.com/" target=_blank><font color=#3b5998>http://map.zhongsou.com</font></a><br><br>  76.图片标签快速生成工具      <br><br>  <a href="http://www.eoool.com/" target=_blank><font color=#3b5998>http://www.eoool.com/</font></a><br><br>  77.查询在google所有服务器中的PR值 <br><br>  <a href="http://www.iwebtool.com/pagerank_checker domain=www.XXXXXoob.com" target=_blank><font color=#3b5998>http://www.iwebtool.com/pagerank_checker domain=www.XXXXXoob.com</font></a><br><br>  78.免费加入140个搜索引擎     <br><br>  <a href="http://freehosting.hostrave.com/p/ledbetter/submitware/index.php" target=_blank><font color=#3b5998>http://freehosting.hostrave.com/p/ledbetter/submitware/index.php</font></a><br><br>  79.在线生成多种样式的LOGO <a href="http://sherlocco.com/create.asp" target=_blank><font color=#3b5998>http://sherlocco.com/create.asp</font></a><br><br>  80.街道路牌签名生成器       <br><br>  <a href="http://www.streetsigngenerator.com/" target=_blank><font color=#3b5998>http://www.streetsigngenerator.com/</font></a><br><br>  81.blog标签图片80&#215;15/80&#215;31制作 <br><br>  <a href="http://button.blogflux.com/" target=_blank><font color=#3b5998>http://button.blogflux.com/</font></a><br><br>  82.在线生成漫画小图像的站     <br><br>  <a href="http://www.abi-station.com/tchinese/" target=_blank><font color=#3b5998>http://www.abi-station.com/tchinese/</font></a><br><br>  83.生成邮址图片\条形码生成\印章  <br><br>  <a href="http://www.makepic.com/" target=_blank><font color=#3b5998>http://www.makepic.com/</font></a><br><br>  84.QQ在线状态代码生成       <br><br>  <a href="http://is.qq.com/webpresence/code.shtml" target=_blank><font color=#3b5998>http://is.qq.com/webpresence/code.shtml</font></a><br><br>  85.身份证号码在线生成器-韩国/台湾 <br><br>  <a href="http://i972.net/~gen/" target=_blank><font color=#3b5998>http://i972.net/~gen/</font></a><br><br>  86.条形码在线生成器        <br><br>  <a href="http://www.gzbonny.com/asp/barcode.asp" target=_blank><font color=#3b5998>http://www.gzbonny.com/asp/barcode.asp</font></a><br><br>  87.聊天工具在线状态生成器     <br><br>  <a href="http://www.onlinestatus.org/usage.php" target=_blank><font color=#3b5998>http://www.onlinestatus.org/usage.php</font></a><br><br>  88.在线字体生成工具        <br><br>  <a href="http://www.youmade.com/" target=_blank><font color=#3b5998>http://www.logomaker.cn/</font></a><br><br>  90.在线制作卡通头像        <br><br>  <a href="http://cartoon.msn.com.cn/" target=_blank><font color=#3b5998>http://cartoon.msn.com.cn/</font></a><br><br>  91.网站综合信息查询        <br><br>  <a href="http://www.webmasterhome.cn/" target=_blank><font color=#3b5998>http://www.webmasterhome.cn/</font></a><br><br>  92.在线制作按钮(多种款式)     <br><br>  <a href="http://www.buttonator.com/" target=_blank><font color=#3b5998>http://www.buttonator.com</font></a><br><br>  93.在线建立您的Web 2.0网站LOGO  <br><br>  <a href="http://web2.0stylr.com/" target=_blank><font color=#3b5998>http://web2.0stylr.com</font></a><br><br>  94.在线生成彩字(爱狗狗吧)     <br><br>  <a href="http://www.igogo8.com/" target=_blank><font color=#3b5998>http://www.igogo8.com/</font></a><br><br>  95.live个性图标在线制作      <br><br>  <a href="http://linux-fans.com/email/live/live.php" target=_blank><font color=#3b5998>http://linux-fans.com/email/live/live.php</font></a><br><br>  96.在线(IE版)图像处理工具     <br><br>  <a href="http://www1.iephotoshop.com/" target=_blank><font color=#3b5998>http://www1.iephotoshop.com/</font></a><br><br>  97.ajax载入效果          <br><br>  <a href="http://ajaxload.info/" target=_blank><font color=#3b5998>http://ajaxload.info/</font></a><br><br>  98.报纸头条图片生成器       <br><br>  <a href="http://www.onlinewahn.de/generator/z-maker.htm" target=_blank><font color=#3b5998>http://www.onlinewahn.de/generator/z-maker.htm</font></a><br><br>  99.杂志封面生成器         <br><br>  <a href="http://www.funonit.com/funny_jokes/fake_magazine" target=_blank><font color=#3b5998>http://www.funonit.com/funny_jokes/fake_magazine</font></a><br><br>  100.MD5加密破解查询        <br><br>  <a href="http://www.md5.org.cn/" target=_blank><font color=#3b5998>http://www.md5.org.cn/</font></a><br><br>  102.批量查询未注册域名       <br><br>  <a href="http://www.moniker.com/domains/batch_reg.jsp" target=_blank><font color=#3b5998>http://www.moniker.com/domains/batch_reg.jsp

Asp.Net数据库帮助类SQLHelper.cs


using System;
using System.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;

namespace AcrossDB.Utils
{
    /// <summary>
    ///微软的SqlHelper3.0 
    /// </summary>
    public sealed class SqlHelper
    {
        #region 私有方法,属性和构造函数
        public static readonly string ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
        public static readonly string ConnectionString2 = ConfigurationManager.AppSettings["ConnectionString2"].ToString();
        //public static readonly string userconnection = ConfigurationManager.AppSettings["SqlConnUser"].ToString();
        //public static readonly string siteconnection = ConfigurationManager.AppSettings["SqlConnSite"].ToString();
        
        private SqlHelper() { }

        /// <summary>
        ///添加参数
        /// </summary>
        /// <param name="command">SqlCommand对象</param>
        /// <param name="commandParameters">SqlParamete参数数组</param>
        private static void AttachParameters(SqlCommand command, SqlParameter[] commandParameters)
        {
            //RockeyMssage.ValidationRk();
            //Timer.EmptySessionFile();
            if (command == null) throw new ArgumentNullException("command");
            if (commandParameters != null)
            {
                foreach (SqlParameter p in commandParameters)
                {
                    if (p != null)
                    {
                        // Check for derived output value with no value assigned
                        if ((p.Direction == ParameterDirection.InputOutput ||
                            p.Direction == ParameterDirection.Input) &&
                            (p.Value == null))
                        {
                            p.Value = DBNull.Value;
                        }
                        command.Parameters.Add(p);
                    }
                }
            }
        }

        /// <summary>
        /// 分配参数值
        /// </summary>
        /// <param name="commandParameters">要分配参数值的参数数组</param>
        /// <param name="dataRow">存储参数值的DataRow</param>
        private static void AssignParameterValues(SqlParameter[] commandParameters, DataRow dataRow)
        {
            if ((commandParameters == null) || (dataRow == null))
            {
                return;
            }

            int i = 0;
            foreach (SqlParameter commandParameter in commandParameters)
            {
                if (commandParameter.ParameterName == null ||
                    commandParameter.ParameterName.Length <= 1)
                    throw new Exception(
                        string.Format(
                            "Please provide a valid parameter name on the parameter #{0}, the ParameterName property has the following value: '{1}'.",
                            i, commandParameter.ParameterName));
                if (dataRow.Table.Columns.IndexOf(commandParameter.ParameterName.Substring(1)) != -1)
                    commandParameter.Value = dataRow[commandParameter.ParameterName.Substring(1)];
                i++;
            }
        }

        /// <summary>
        ///分配参数值
        /// </summary>
        /// <param name="commandParameters">要分配参数值的参数数组</param>
        /// <param name="parameterValues">存储参数值的object对象数组</param>
        private static void AssignParameterValues(SqlParameter[] commandParameters, object[] parameterValues)
        {
            if ((commandParameters == null) || (parameterValues == null))
            {
                return;
            }
            if (commandParameters.Length != parameterValues.Length)
            {
                throw new ArgumentException("Parameter count does not match Parameter Value count.");
            }

            for (int i = 0, j = commandParameters.Length; i < j; i++)
            {
                if (parameterValues[i] is IDbDataParameter)
                {
                    IDbDataParameter paramInstance = (IDbDataParameter)parameterValues[i];
                    if (paramInstance.Value == null)
                    {
                        commandParameters[i].Value = DBNull.Value;
                    }
                    else
                    {
                        commandParameters[i].Value = paramInstance.Value;
                    }
                }
                else if (parameterValues[i] == null)
                {
                    commandParameters[i].Value = DBNull.Value;
                }
                else
                {
                    commandParameters[i].Value = parameterValues[i];
                }
            }
        }

        /// <summary>
        /// 打开(如果需要),分配连接,事务,command类型和参数给一个commandconnection, transaction, command type and parameters 
        /// </summary>
        /// <param name="command">预准备SqlCommand对象</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务或null</param>
        /// <param name="commandType">命令类型,文本,存储过程等</param>
        /// <param name="commandText">存储过程或命令的文本</param>
        /// <param name="commandParameters">命令参数或为null</param>
        /// <param name="mustCloseConnection"><c>true</c> 是否必须关闭连接</param>
        private static void PrepareCommand(SqlCommand command, SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters, out bool mustCloseConnection)
        {
            if (command == null) throw new ArgumentNullException("command");
            if (commandText == null || commandText.Length == 0) throw new ArgumentNullException("commandText");
            if (connection.State != ConnectionState.Open)
            {
                mustCloseConnection = true;
                connection.Open();
            }
            else
            {
                mustCloseConnection = false;
            }
            command.Connection = connection;
            command.CommandText = commandText;
            if (transaction != null)
            {
                if (transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
                command.Transaction = transaction;
            }
            command.CommandType = commandType;

            if (commandParameters != null)
            {
                AttachParameters(command, commandParameters);
            }
            return;
        }

        #endregion 私有方法和构造函数

        #region ExecuteNonQuery

        /// <summary>
        /// 执行SqlCommand 
        /// </summary>
        /// <remarks>
        /// 例子:
        ///  int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders");
        /// </remarks>
        /// <param name="connectionString">连接字符串</param>
        /// <param name="commandType">命令类型</param>
        /// <param name="commandText">存储过程或sql命令文本</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText)
        {
            return ExecuteNonQuery(connectionString, commandType, commandText, (SqlParameter[])null);
        }
        public static int ExecuteNonQuery(CommandType commandType, string commandText)
        {
            return ExecuteNonQuery(ConnectionString, commandType, commandText);
        }
        public static int ExecuteNonQuery(CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            return ExecuteNonQuery(ConnectionString, commandType, commandText, commandParameters);
        }
        /// <summary>
        ///  执行SqlCommand 
        /// </summary>
        /// <remarks>
        /// 例子.:  
        ///  int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connectionString">连接字符串</param>
        /// <param name="commandType">命令类型</param>
        /// <param name="commandText">存储过程或sql命令文本</param>
        /// <param name="commandParameters">命令参数</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                return ExecuteNonQuery(connection, commandType, commandText, commandParameters);
            }
        }

        /// <summary>
        /// 执行SqlCommand
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子:  
        ///  int result = ExecuteNonQuery(connString, "PublishOrders", 24, 36);
        /// </remarks>
        /// <param name="connectionString">连接字符串</param>
        /// <param name="spName">The name of the stored prcedure</param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteNonQuery(string connectionString, string spName, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlConnection. 
        /// </summary>
        /// <remarks>
        /// 例子:  
        ///  int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders");
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="commandType">命令类型</param>
        /// <param name="commandText">存储过程或sql命令文本</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteNonQuery(connection, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// 使用参数执行没有过返回结果的SqlCommand命令对象Execute a SqlCommand (that returns no resultset) against the specified SqlConnection 
        /// </summary>
        /// <remarks>
        /// 例子:  
        ///  int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="commandType">命令类型</param>
        /// <param name="commandText">存储过程或sql命令文本</param>
        /// <param name="commandParameters">命令参数</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null) throw new ArgumentNullException("connection");

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);
            int retval = cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();
            if (mustCloseConnection)
                connection.Close();
            return retval;
        }

        /// <summary>
        /// 使用提供的参数执行没有返回结果的存储过程
        /// </summary>
        /// <remarks>
        /// 些方法不能获取存储过程的输出参数和返回值
        /// 
        /// 例子:  
        ///  int result = ExecuteNonQuery(conn, "PublishOrders", 24, 36);
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="parameterValues">分配对象数组给存储过程作为输入参数</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteNonQuery(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteNonQuery(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteNonQuery(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// 执行无参数,无返回结果集的SqlCommand命令
        /// </summary>
        /// <remarks>
        /// 例子:  
        ///  int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders");
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="commandType">命令类型</param>
        /// <param name="commandText">存储过程或sql命令文本</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteNonQuery(transaction, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// 用提供的参数执行无返回结果集的SqlCommand命令
        /// </summary>
        /// <remarks>
        /// 例子:  
        ///  int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="commandType">命令类型</param>
        /// <param name="commandText">存储过程或sql命令文本</param>
        /// <param name="commandParameters">命令参数</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);

            // Finally, execute the command
            int retval = cmd.ExecuteNonQuery();

            // Detach the SqlParameters from the command object, so they can be used again
            cmd.Parameters.Clear();
            return retval;
        }

        /// <summary>
        ///使用事务执行无返回结果集的SqlCommand命令
        /// </summary>
        /// <remarks>
        /// 这个例子不能访问存储过程的输出参数和返回值
        /// 
        /// 例子:  
        ///  int result = ExecuteNonQuery(conn, trans, "PublishOrders", 24, 36);
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteNonQuery(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName);
            }
        }

        #endregion ExecuteNonQuery

        #region ExecuteDataset

        /// <summary>
        /// 执行SqlCommand,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子:   
        ///  DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="connectionString">合法的连接字符串</param>
        /// <param name="commandType">命令类型(stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名或sql的命令</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)
        {
            return ExecuteDataset(connectionString, commandType, commandText, (SqlParameter[])null);
        }
        public static DataSet ExecuteDataset(CommandType commandType, string commandText)
        {
            return ExecuteDataset(ConnectionString, commandType, commandText);
        }
        public static DataSet ExecuteDataset(CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            return ExecuteDataset(ConnectionString, commandType, commandText, commandParameters);
        }
        /// <summary>
        /// 执行SqlCommand,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="commandParameters">SqlParamter数组</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");

            // Create & open a SqlConnection, and dispose of it after we are done
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                // Call the overload that takes a connection in place of the connection string
                return ExecuteDataset(connection, commandType, commandText, commandParameters);
            }
        }

        /// <summary>
        ///    调用存储过程,返回数据集体
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  DataSet ds = ExecuteDataset(connString, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDataset(string connectionString, string spName, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteDataset(connection, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection 
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="commandParameters">SqlParamter数组</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null) throw new ArgumentNullException("connection");

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);

            // Create the DataAdapter & DataSet
            using (SqlDataAdapter da = new SqlDataAdapter(cmd))
            {
                DataSet ds = new DataSet();

                // Fill the DataSet using default values for DataTable names, etc
                da.Fill(ds);

                // Detach the SqlParameters from the command object, so they can be used again
                cmd.Parameters.Clear();

                if (mustCloseConnection)
                    connection.Close();

                // Return the dataset
                return ds;
            }
        }

        /// <summary>
        ///调用存储过程,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataSet ds = ExecuteDataset(conn, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDataset(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteDataset(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteDataset(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        ///通过事务执行命令对象,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDataset(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteDataset(transaction, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// 通过事务执行命令对象,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="commandParameters">SqlParamter数组</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDataset(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);

            // Create the DataAdapter & DataSet
            using (SqlDataAdapter da = new SqlDataAdapter(cmd))
            {
                DataSet ds = new DataSet();

                // Fill the DataSet using default values for DataTable names, etc
                da.Fill(ds);

                // Detach the SqlParameters from the command object, so they can be used again
                cmd.Parameters.Clear();

                // Return the dataset
                return ds;
            }
        }

        /// <summary>
        /// 利用事务,通过SqlCommand执行存储过程 
        /// </summary>
        /// <remarks>

        /// 例子: 
        ///  DataSet ds = ExecuteDataset(trans, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDataset(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteDataset(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteDataset(transaction, CommandType.StoredProcedure, spName);
            }
        }

        #endregion ExecuteDataset

        #region ExecuteDataTable

        /// <summary>
        /// 执行SqlCommand,返回数据表
        /// </summary>
        /// <remarks>
        /// 例子:   
        ///  DataTable dt = ExecuteDataTable(connString, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="connectionString">合法的连接字符串</param>
        /// <param name="commandType">命令类型(stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名或sql的命令</param>
        /// <returns>数据集</returns>
        public static DataTable ExecuteDataTable(string connectionString, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteDataTable(connectionString, commandType, commandText, (SqlParameter[])null);
        }
        public static DataTable ExecuteDataTable(CommandType commandType, string commandText)
        {
            return ExecuteDataTable(ConnectionString, commandType, commandText);
        }
        public static DataTable ExecuteDataTable(CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            return ExecuteDataTable(ConnectionString, commandType, commandText, commandParameters);
        }
        /// <summary>
        /// 执行SqlCommand,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataTable dt = ExecuteDataTable(connString, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="commandParameters">SqlParamter数组</param>
        /// <returns>数据集</returns>
        public static DataTable ExecuteDataTable(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");

            // Create & open a SqlConnection, and dispose of it after we are done
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                // Call the overload that takes a connection in place of the connection string
                return ExecuteDataTable(connection, commandType, commandText, commandParameters);
            }
        }

        /// <summary>
        ///    调用存储过程,返回数据集体
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  DataTable dt = ExecuteDataTable(connString, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        /// <returns>数据集</returns>
        public static DataTable ExecuteDataTable(string connectionString, string spName, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteDataTable(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteDataTable(connectionString, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataTable dt = ExecuteDataTable(conn, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <returns>数据集</returns>
        public static DataTable ExecuteDataTable(SqlConnection connection, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteDataTable(connection, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// 返回DataTable
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataTalbe dt = ExecuteDataTable(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="commandParameters">SqlParamter数组</param>
        /// <returns>数据集</returns>
        public static DataTable ExecuteDataTable(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null) throw new ArgumentNullException("connection");

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);

            // Create the DataAdapter & DataSet
            using (SqlDataAdapter da = new SqlDataAdapter(cmd))
            {
                DataTable dt = new DataTable();
                // Fill the DataSet using default values for DataTable names, etc
                da.Fill(dt);

                // Detach the SqlParameters from the command object, so they can be used again
                cmd.Parameters.Clear();

                if (mustCloseConnection)
                    connection.Close();

                // Return the dataset
                return dt;
            }
        }

        /// <summary>
        ///调用存储过程,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataTable dt = ExecuteDataTable(conn, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        /// <returns>数据集</returns>
        public static DataTable ExecuteDataTable(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteDataTable(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteDataTable(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        ///通过事务执行命令对象,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataTable dt = ExecuteDataTable(trans, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <returns>数据集</returns>
        public static DataTable ExecuteDataTable(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteDataTable(transaction, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// 通过事务执行命令对象,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  DataTable dt = ExecuteDataTable(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="commandParameters">SqlParamter数组</param>
        /// <returns>数据集</returns>
        public static DataTable ExecuteDataTable(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);

            // Create the DataAdapter & DataSet
            using (SqlDataAdapter da = new SqlDataAdapter(cmd))
            {
                DataTable dt = new DataTable();
                // Fill the DataSet using default values for DataTable names, etc
                da.Fill(dt);

                // Detach the SqlParameters from the command object, so they can be used again
                cmd.Parameters.Clear();

                // Return the dataset
                return dt;
            }
        }

        /// <summary>
        /// 利用事务,通过SqlCommand执行存储过程 
        /// </summary>
        /// <remarks>

        /// 例子: 
        ///  DataTable dt = ExecuteDataTable(trans, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        /// <returns>数据集</returns>
        public static DataTable ExecuteDataTable(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteDataTable(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteDataTable(transaction, CommandType.StoredProcedure, spName);
            }
        }

        #endregion ExecuteDataTable

        #region ExecuteReader

        /// <summary>
        /// 决定连通接着关闭的方式
        /// </summary>
        private enum SqlConnectionOwnership
        {
            /// <summary>连接属于SqlHelper并由它管理</summary>
            Internal,
            /// <summary>连接属于SqlHelper的调用者并由它管理</summary>
            External
        }
        /// <summary>
        /// Create and prepare a SqlCommand, and call ExecuteReader with the appropriate CommandBehavior.
        /// </summary>
        /// <remarks>
        /// If we created and opened the connection, we want the connection to be closed when the DataReader is closed.
        /// 
        /// If the caller provided the connection, we want to leave it to them to manage.
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="transaction">合法的事务或null</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <param name="commandParameters">SqlParamters数组 to be associated with the command or 'null' if no parameters are required</param>
        /// <param name="connectionOwnership">Indicates whether the connection parameter was provided by the caller, or created by SqlHelper</param>
        /// <returns>SqlDataReader containing the results of the command</returns>
        private static SqlDataReader ExecuteReader(SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters, SqlConnectionOwnership connectionOwnership)
        {
            if (connection == null) throw new ArgumentNullException("connection");

            bool mustCloseConnection = false;
            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            try
            {
                PrepareCommand(cmd, connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);

                // Create a reader
                SqlDataReader dataReader;

                // Call ExecuteReader with the appropriate CommandBehavior
                if (connectionOwnership == SqlConnectionOwnership.External)
                {
                    dataReader = cmd.ExecuteReader();
                }
                else
                {
                    dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                }

                // Detach the SqlParameters from the command object, so they can be used again.
                // HACK: There is a problem here, the output parameter values are fletched 
                // when the reader is closed, so if the parameters are detached from the command
                // then the SqlReader can磘 set its values. 
                // When this happen, the parameters can磘 be used again in other command.
                bool canClear = true;
                foreach (SqlParameter commandParameter in cmd.Parameters)
                {
                    if (commandParameter.Direction != ParameterDirection.Input)
                        canClear = false;
                }

                if (canClear)
                {
                    cmd.Parameters.Clear();
                }

                return dataReader;
            }
            catch
            {
                if (mustCloseConnection)
                    connection.Close();
                throw;
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in 
        /// the connection string. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  SqlDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteReader(connectionString, commandType, commandText, (SqlParameter[])null);
        }
        public static SqlDataReader ExecuteReader(CommandType commandType, string commandText)
        {
            return ExecuteReader(ConnectionString, commandType, commandText);
        }
        public static SqlDataReader ExecuteReader(CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            return ExecuteReader(ConnectionString, commandType, commandText, commandParameters);
        }
        /// <summary>
        /// Execute a SqlCommand (that returns a resultset) against the database specified in the connection string 
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  SqlDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <param name="commandParameters">SqlParamters数组 used to execute the command</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            SqlConnection connection = null;
            try
            {
                connection = new SqlConnection(connectionString);
                connection.Open();

                // Call the private overload that takes an internally owned connection in place of the connection string
                return ExecuteReader(connection, null, commandType, commandText, commandParameters, SqlConnectionOwnership.Internal);
            }
            catch
            {
                // If we fail to return the SqlDatReader, we need to close the connection ourselves
                if (connection != null) connection.Close();
                throw;
            }

        }

        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in 
        /// the connection string using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  SqlDataReader dr = ExecuteReader(connString, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReader(string connectionString, string spName, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                AssignParameterValues(commandParameters, parameterValues);

                return ExecuteReader(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteReader(connectionString, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  SqlDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="connection">A valid SqlConnection</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteReader(connection, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection 
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  SqlDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">A valid SqlConnection</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <param name="commandParameters">SqlParamters数组 used to execute the command</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            // Pass through the call to the private overload using a null transaction value and an externally owned connection
            return ExecuteReader(connection, (SqlTransaction)null, commandType, commandText, commandParameters, SqlConnectionOwnership.External);
        }

        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection 
        /// using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  SqlDataReader dr = ExecuteReader(conn, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="connection">A valid SqlConnection</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReader(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                AssignParameterValues(commandParameters, parameterValues);

                return ExecuteReader(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteReader(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  SqlDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="transaction">A valid SqlTransaction</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteReader(transaction, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///   SqlDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="transaction">A valid SqlTransaction</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <param name="commandParameters">SqlParamters数组 used to execute the command</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");

            // Pass through to private overload, indicating that the connection is owned by the caller
            return ExecuteReader(transaction.Connection, transaction, commandType, commandText, commandParameters, SqlConnectionOwnership.External);
        }

        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified
        /// SqlTransaction using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  SqlDataReader dr = ExecuteReader(trans, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="transaction">A valid SqlTransaction</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReader(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                AssignParameterValues(commandParameters, parameterValues);

                return ExecuteReader(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteReader(transaction, CommandType.StoredProcedure, spName);
            }
        }

        #endregion ExecuteReader

        #region ExecuteScalar

        /// <summary>
        /// Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the database specified in 
        /// the connection string. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount");
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <returns>对象</returns>
        public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteScalar(connectionString, commandType, commandText, (SqlParameter[])null);
        }
        public static object ExecuteScalar(CommandType commandType, string commandText)
        {
            return ExecuteScalar(ConnectionString, commandType, commandText);
        }
        public static object ExecuteScalar(CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            return ExecuteScalar(ConnectionString, commandType, commandText, commandParameters);
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a 1x1 resultset) against the database specified in the connection string 
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <param name="commandParameters">SqlParamters数组 used to execute the command</param>
        /// <returns>对象</returns>
        public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            // Create & open a SqlConnection, and dispose of it after we are done
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                // Call the overload that takes a connection in place of the connection string
                return ExecuteScalar(connection, commandType, commandText, commandParameters);
            }
        }

        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the database specified in 
        /// the connection string using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  int orderCount = (int)ExecuteScalar(connString, "GetOrderCount", 24, 36);
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
        /// <returns>对象</returns>
        public static object ExecuteScalar(string connectionString, string spName, params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlConnection. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount");
        /// </remarks>
        /// <param name="connection">A valid SqlConnection</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <returns>对象</returns>
        public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteScalar(connection, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection 
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">A valid SqlConnection</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <param name="commandParameters">SqlParamters数组 used to execute the command</param>
        /// <returns>对象</returns>
        public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null) throw new ArgumentNullException("connection");

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();

            bool mustCloseConnection = false;
            PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);

            // Execute the command & return the results
            object retval = cmd.ExecuteScalar();

            // Detach the SqlParameters from the command object, so they can be used again
            cmd.Parameters.Clear();

            if (mustCloseConnection)
                connection.Close();

            return retval;
        }

        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection 
        /// using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  int orderCount = (int)ExecuteScalar(conn, "GetOrderCount", 24, 36);
        /// </remarks>
        /// <param name="connection">A valid SqlConnection</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
        /// <returns>对象</returns>
        public static object ExecuteScalar(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteScalar(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteScalar(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlTransaction. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount");
        /// </remarks>
        /// <param name="transaction">A valid SqlTransaction</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <returns>对象</returns>
        public static object ExecuteScalar(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteScalar(transaction, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="transaction">A valid SqlTransaction</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <param name="commandParameters">SqlParamters数组 used to execute the command</param>
        /// <returns>对象</returns>
        public static object ExecuteScalar(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);

            // Execute the command & return the results
            object retval = cmd.ExecuteScalar();

            // Detach the SqlParameters from the command object, so they can be used again
            cmd.Parameters.Clear();
            return retval;
        }

        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified
        /// SqlTransaction using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  int orderCount = (int)ExecuteScalar(trans, "GetOrderCount", 24, 36);
        /// </remarks>
        /// <param name="transaction">A valid SqlTransaction</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
        /// <returns>对象</returns>
        public static object ExecuteScalar(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // PPull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteScalar(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteScalar(transaction, CommandType.StoredProcedure, spName);
            }
        }

        #endregion ExecuteScalar

        #region ExecuteXmlReader
        /// <summary>
        /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  XmlReader r = ExecuteXmlReader(conn, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="connection">A valid SqlConnection</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令 using "FOR XML AUTO"</param>
        /// <returns>An XmlReader containing the resultset generated by the command</returns>
        public static XmlReader ExecuteXmlReader(SqlConnection connection, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteXmlReader(connection, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection 
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  XmlReader r = ExecuteXmlReader(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">A valid SqlConnection</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令 using "FOR XML AUTO"</param>
        /// <param name="commandParameters">SqlParamters数组 used to execute the command</param>
        /// <returns>An XmlReader containing the resultset generated by the command</returns>
        public static XmlReader ExecuteXmlReader(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (connection == null) throw new ArgumentNullException("connection");

            bool mustCloseConnection = false;
            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            try
            {
                PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);

                // Create the DataAdapter & DataTable
                XmlReader retval = cmd.ExecuteXmlReader();

                // Detach the SqlParameters from the command object, so they can be used again
                cmd.Parameters.Clear();

                return retval;
            }
            catch
            {
                if (mustCloseConnection)
                    connection.Close();
                throw;
            }
        }

        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection 
        /// using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  XmlReader r = ExecuteXmlReader(conn, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="connection">A valid SqlConnection</param>
        /// <param name="spName">存储过程的名字 using "FOR XML AUTO"</param>
        /// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
        /// <returns>An XmlReader containing the resultset generated by the command</returns>
        public static XmlReader ExecuteXmlReader(SqlConnection connection, string spName, params object[] parameterValues)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteXmlReader(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteXmlReader(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  XmlReader r = ExecuteXmlReader(trans, CommandType.StoredProcedure, "GetOrders");
        /// </remarks>
        /// <param name="transaction">A valid SqlTransaction</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令 using "FOR XML AUTO"</param>
        /// <returns>An XmlReader containing the resultset generated by the command</returns>
        public static XmlReader ExecuteXmlReader(SqlTransaction transaction, CommandType commandType, string commandText)
        {
            // Pass through the call providing null for the set of SqlParameters
            return ExecuteXmlReader(transaction, commandType, commandText, (SqlParameter[])null);
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  XmlReader r = ExecuteXmlReader(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="transaction">A valid SqlTransaction</param>
        /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程的名字或sql命令 using "FOR XML AUTO"</param>
        /// <param name="commandParameters">SqlParamters数组 used to execute the command</param>
        /// <returns>An XmlReader containing the resultset generated by the command</returns>
        public static XmlReader ExecuteXmlReader(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");

            // Create a command and prepare it for execution
            SqlCommand cmd = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);

            // Create the DataAdapter & DataTable
            XmlReader retval = cmd.ExecuteXmlReader();

            // Detach the SqlParameters from the command object, so they can be used again
            cmd.Parameters.Clear();
            return retval;
        }

        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified 
        /// SqlTransaction using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  XmlReader r = ExecuteXmlReader(trans, "GetOrders", 24, 36);
        /// </remarks>
        /// <param name="transaction">A valid SqlTransaction</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="parameterValues">An array of objects to be assigned as the input values of the stored procedure</param>
        /// <returns>数据集</returns>
        public static XmlReader ExecuteXmlReader(SqlTransaction transaction, string spName, params object[] parameterValues)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                return ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                return ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName);
            }
        }

        #endregion ExecuteXmlReader

        #region FillDataset
        /// <summary>
        /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in 
        /// the connection string. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名</param>
        public static void FillDataset(string connectionString, CommandType commandType, string commandText, DataTable dataSet, string[] tableNames)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (dataSet == null) throw new ArgumentNullException("dataSet");

            // Create & open a SqlConnection, and dispose of it after we are done
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                // Call the overload that takes a connection in place of the connection string
                FillDataset(connection, commandType, commandText, dataSet, tableNames);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset) against the database specified in the connection string 
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="commandParameters">SqlParamter数组</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名

        /// </param>
        public static void FillDataset(string connectionString, CommandType commandType,
            string commandText, DataTable dataSet, string[] tableNames,
            params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (dataSet == null) throw new ArgumentNullException("dataSet");
            // Create & open a SqlConnection, and dispose of it after we are done
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                // Call the overload that takes a connection in place of the connection string
                FillDataset(connection, commandType, commandText, dataSet, tableNames, commandParameters);
            }
        }

        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in 
        /// the connection string using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, 24);
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名

        /// </param>    
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        public static void FillDataset(string connectionString, string spName,
            DataTable dataSet, string[] tableNames,
            params object[] parameterValues)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (dataSet == null) throw new ArgumentNullException("dataSet");
            // Create & open a SqlConnection, and dispose of it after we are done
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                // Call the overload that takes a connection in place of the connection string
                FillDataset(connection, spName, dataSet, tableNames, parameterValues);
            }
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection. 
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  FillDataset(conn, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名

        /// </param>    
        public static void FillDataset(SqlConnection connection, CommandType commandType,
            string commandText, DataTable dataSet, string[] tableNames)
        {
            FillDataset(connection, commandType, commandText, dataSet, tableNames, null);
        }

        /// <summary>
        /// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection 
        /// using the provided parameters.
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  FillDataset(conn, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名

        /// </param>
        /// <param name="commandParameters">SqlParamter数组</param>
        public static void FillDataset(SqlConnection connection, CommandType commandType,
            string commandText, DataTable dataSet, string[] tableNames,
            params SqlParameter[] commandParameters)
        {
            FillDataset(connection, null, commandType, commandText, dataSet, tableNames, commandParameters);
        }

        /// <summary>
        ///调用存储过程,返回数据集
        /// using the provided parameter values.  This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  FillDataset(conn, "GetOrders", ds, new string[] {"orders"}, 24, 36);
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名

        /// </param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        public static void FillDataset(SqlConnection connection, string spName, DataTable dataSet, string[] tableNames, params object[] parameterValues)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (dataSet == null) throw new ArgumentNullException("dataSet");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                FillDataset(connection, CommandType.StoredProcedure, spName, dataSet, tableNames, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                FillDataset(connection, CommandType.StoredProcedure, spName, dataSet, tableNames);
            }
        }

        /// <summary>
        /// 执行SqlCommand对象,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  FillDataset(trans, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名 
        /// </param>
        public static void FillDataset(SqlTransaction transaction, CommandType commandType,
            string commandText,
            DataTable dataSet, string[] tableNames)
        {
            FillDataset(transaction, commandType, commandText, dataSet, tableNames, null);
        }

        /// <summary>
        ///执行SqlCommand对象,返回数据集
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  FillDataset(trans, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名

        /// </param>
        /// <param name="commandParameters">SqlParamter数组</param>
        public static void FillDataset(SqlTransaction transaction, CommandType commandType,
            string commandText, DataTable dataSet, string[] tableNames,
            params SqlParameter[] commandParameters)
        {
            FillDataset(transaction.Connection, transaction, commandType, commandText, dataSet, tableNames, commandParameters);
        }

        /// <summary>
        /// 执行SqlCommand对象,返回数据集
        /// </summary>
        /// <remarks>
        /// This method provides no access to output parameters or the stored procedure's return value parameter.
        /// 
        /// 例子: 
        ///  FillDataset(trans, "GetOrders", ds, new string[]{"orders"}, 24, 36);
        /// </remarks>
        /// <param name="transaction">合法的事务</param>
        /// <param name="spName">存储过程名字</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名
        /// </param>
        /// <param name="parameterValues">分配给存储过程作为输入参数的对象数组</param>
        public static void FillDataset(SqlTransaction transaction, string spName,
            DataTable dataSet, string[] tableNames,
            params object[] parameterValues)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (dataSet == null) throw new ArgumentNullException("dataSet");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If we receive parameter values, we need to figure out where they go
            if ((parameterValues != null) && (parameterValues.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Assign the provided values to these parameters based on parameter order
                AssignParameterValues(commandParameters, parameterValues);

                // Call the overload that takes SqlParamters数组
                FillDataset(transaction, CommandType.StoredProcedure, spName, dataSet, tableNames, commandParameters);
            }
            else
            {
                // Otherwise we can just call the SP without params
                FillDataset(transaction, CommandType.StoredProcedure, spName, dataSet, tableNames);
            }
        }

        /// <summary>
        ///执行SqlCommand对象,返回数据集
        /// <remarks>
        /// 例子: 
        ///  FillDataset(conn, trans, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="transaction">合法的事务</param>
        /// <param name="commandType">命令类型 (stored procedure, text, 等)</param>
        /// <param name="commandText">存储过程名字或sql命令</param>
        /// <param name="dataSet"数据集</param>
        /// <param name="tableNames">表名
        /// </param>
        /// <param name="commandParameters">SqlParamter数组</param>
        private static void FillDataset(SqlConnection connection, SqlTransaction transaction, CommandType commandType,
            string commandText, DataTable dataSet, string[] tableNames,
            params SqlParameter[] commandParameters)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (dataSet == null) throw new ArgumentNullException("dataSet");

            // Create a command and prepare it for execution
            SqlCommand command = new SqlCommand();
            bool mustCloseConnection = false;
            PrepareCommand(command, connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection);

            // Create the DataAdapter & DataTable
            using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command))
            {

                // Add the table mappings specified by the user
                if (tableNames != null && tableNames.Length > 0)
                {
                    string tableName = "Table";
                    for (int index = 0; index < tableNames.Length; index++)
                    {
                        if (tableNames[index] == null || tableNames[index].Length == 0) throw new ArgumentException("The tableNames parameter must contain a list of tables, a value was provided as null or empty string.", "tableNames");
                        dataAdapter.TableMappings.Add(tableName, tableNames[index]);
                        tableName += (index + 1).ToString();
                    }
                }

                // Fill the DataTable using default values for DataTable names, etc
                dataAdapter.Fill(dataSet);

                // Detach the SqlParameters from the command object, so they can be used again
                command.Parameters.Clear();
            }

            if (mustCloseConnection)
                connection.Close();
        }
        #endregion

        //#region UpdateDataset
        ///// <summary>
        /////  执行SqlCommand对象,返回数据集
        ///// </summary>
        ///// <remarks>
        ///// 例子: 
        /////  UpdateDataset(conn, insertCommand, deleteCommand, updateCommand, dataSet, "Order");
        ///// </remarks>
        ///// <param name="insertCommand">插入命令对象</param>
        ///// <param name="deleteCommand">删除命令对象</param>
        ///// <param name="updateCommand">更新命令对象</param>
        ///// <param name="dataSet">数据集</param>
        ///// <param name="tableName">表名</param>
        //public static void UpdateDataset(SqlCommand insertCommand, SqlCommand deleteCommand, SqlCommand updateCommand, DataTable dataSet, string tableName)
        //{
        //    if (insertCommand == null) throw new ArgumentNullException("insertCommand");
        //    if (deleteCommand == null) throw new ArgumentNullException("deleteCommand");
        //    if (updateCommand == null) throw new ArgumentNullException("updateCommand");
        //    if (tableName == null || tableName.Length == 0) throw new ArgumentNullException("tableName");

        //    // Create a SqlDataAdapter, and dispose of it after we are done
        //    using (SqlDataAdapter dataAdapter = new SqlDataAdapter())
        //    {
        //        // Set the data adapter commands
        //        dataAdapter.UpdateCommand = updateCommand;
        //        dataAdapter.InsertCommand = insertCommand;
        //        dataAdapter.DeleteCommand = deleteCommand;

        //        // Update the dataset changes in the data source
        //        dataAdapter.Update(dataSet, tableName);

        //        // Commit all the changes made to the DataTable
        //        dataSet.AcceptChanges();
        //    }
        //}
        //#endregion

        #region CreateCommand
        /// <summary>
        /// 创建命令对象
        /// a stored procedure and optional parameters to be provided
        /// </summary>
        /// <remarks>
        /// 例子: 
        ///  SqlCommand command = CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="sourceColumns">提供给存储过程的作为列名的字符串数组</param>
        /// <returns>A valid SqlCommand object</returns>
        public static SqlCommand CreateCommand(SqlConnection connection, string spName, params string[] sourceColumns)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // Create a SqlCommand
            SqlCommand cmd = new SqlCommand(spName, connection);
            cmd.CommandType = CommandType.StoredProcedure;

            // If we receive parameter values, we need to figure out where they go
            if ((sourceColumns != null) && (sourceColumns.Length > 0))
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Assign the provided source columns to these parameters based on parameter order
                for (int index = 0; index < sourceColumns.Length; index++)
                    commandParameters[index].SourceColumn = sourceColumns[index];

                // Attach the discovered parameters to the SqlCommand object
                AttachParameters(cmd, commandParameters);
            }

            return cmd;
        }
        #endregion

        #region ExecuteNonQueryTypedParams
        /// <summary>
        /// 调用存储过程
        /// </summary>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>整型</returns>
        public static int ExecuteNonQueryTypedParams(String connectionString, String spName, DataRow dataRow)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// 调用存储过程Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlConnection 
        /// </summary>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>整型</returns>
        public static int ExecuteNonQueryTypedParams(SqlConnection connection, String spName, DataRow dataRow)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteNonQuery(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteNonQuery(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// 调用存储过程
        /// </summary>
        /// <param name="transaction">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>整型</returns>
        public static int ExecuteNonQueryTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // Sf the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName);
            }
        }
        #endregion

        #region ExecuteDatasetTypedParams
        /// <summary>
        ///调用存储过程
        /// </summary>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDatasetTypedParams(string connectionString, String spName, DataRow dataRow)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            //If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteDataset(connectionString, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// 调用存储过程
        /// </summary>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDatasetTypedParams(SqlConnection connection, String spName, DataRow dataRow)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// 调用存储过程
        /// </summary>
        /// <param name="transaction">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>数据集</returns>
        public static DataSet ExecuteDatasetTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteDataset(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteDataset(transaction, CommandType.StoredProcedure, spName);
            }
        }

        #endregion

        #region ExecuteReaderTypedParams
        /// <summary>
        /// 调用存储过程
        /// </summary>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReaderTypedParams(String connectionString, String spName, DataRow dataRow)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteReader(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteReader(connectionString, CommandType.StoredProcedure, spName);
            }
        }


        /// <summary>
        /// 调用存储过程
        /// </summary>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReaderTypedParams(SqlConnection connection, String spName, DataRow dataRow)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// 调用存储过程
        /// </summary>
        /// <param name="transaction">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>SqlDataReader</returns>
        public static SqlDataReader ExecuteReaderTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteReader(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteReader(transaction, CommandType.StoredProcedure, spName);
            }
        }
        #endregion

        #region ExecuteScalarTypedParams
        /// <summary>
        /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the database specified in 
        /// the connection string using the dataRow column values as the stored procedure's parameters values.
        /// This method will query the database to discover the parameters for the 
        /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
        /// </summary>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>对象</returns>
        public static object ExecuteScalarTypedParams(String connectionString, String spName, DataRow dataRow)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteScalar(connectionString, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteScalar(connectionString, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        /// 返回数量
        /// </summary>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>对象</returns>
        public static object ExecuteScalarTypedParams(SqlConnection connection, String spName, DataRow dataRow)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteScalar(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteScalar(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        ///返回数量
        /// </summary>
        /// <param name="transaction">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>对象</returns>
        public static object ExecuteScalarTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteScalar(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteScalar(transaction, CommandType.StoredProcedure, spName);
            }
        }
        #endregion

        #region ExecuteXmlReaderTypedParams
        /// <summary>
        /// 读取xml,返回XmlReader
        /// </summary>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>XmlReader</returns>
        public static XmlReader ExecuteXmlReaderTypedParams(SqlConnection connection, String spName, DataRow dataRow)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteXmlReader(connection, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteXmlReader(connection, CommandType.StoredProcedure, spName);
            }
        }

        /// <summary>
        ///读取xml,返回XmlReader
        /// </summary>
        /// <param name="transaction">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="dataRow">数据行,保存着存储过程的参数值.</param>
        /// <returns>XmlReader</returns>
        public static XmlReader ExecuteXmlReaderTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
        {
            if (transaction == null) throw new ArgumentNullException("transaction");
            if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            // If the row has values, the store procedure parameters must be initialized
            if (dataRow != null && dataRow.ItemArray.Length > 0)
            {
                // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
                SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);

                // Set the parameters values
                AssignParameterValues(commandParameters, dataRow);

                return SqlHelper.ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName, commandParameters);
            }
            else
            {
                return SqlHelper.ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName);
            }
        }
        #endregion

    }

    /// <summary>
    /// SqlCommand缓存类
    /// </summary>
    public sealed class SqlHelperParameterCache
    {
        #region private methods, variables, and constructors

        //Since this class provides only static methods, make the default constructor private to prevent 
        //instances from being created with "new SqlHelperParameterCache()"
        private SqlHelperParameterCache() { }

        private static Hashtable paramCache = Hashtable.Synchronized(new Hashtable());

        /// <summary>
        /// 取出存储过程的参数列表
        /// </summary>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="includeReturnValueParameter">是否包含返回值参数</param>
        /// <returns>SqlParameter数组</returns>
        private static SqlParameter[] DiscoverSpParameterSet(SqlConnection connection, string spName, bool includeReturnValueParameter)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            SqlCommand cmd = new SqlCommand(spName, connection);
            cmd.CommandType = CommandType.StoredProcedure;

            connection.Open();
            SqlCommandBuilder.DeriveParameters(cmd);
            connection.Close();

            if (!includeReturnValueParameter)
            {
                cmd.Parameters.RemoveAt(0);
            }

            SqlParameter[] discoveredParameters = new SqlParameter[cmd.Parameters.Count];

            cmd.Parameters.CopyTo(discoveredParameters, 0);

            // Init the parameters with a DBNull value
            foreach (SqlParameter discoveredParameter in discoveredParameters)
            {
                discoveredParameter.Value = DBNull.Value;
            }
            return discoveredParameters;
        }

        /// <summary>
        /// 深度复制SqlParamter数组
        /// </summary>
        /// <param name="originalParameters">原始SqlParameter数组</param>
        /// <returns>SqlParameter数组</returns>
        private static SqlParameter[] CloneParameters(SqlParameter[] originalParameters)
        {
            SqlParameter[] clonedParameters = new SqlParameter[originalParameters.Length];

            for (int i = 0, j = originalParameters.Length; i < j; i++)
            {
                clonedParameters[i] = (SqlParameter)((ICloneable)originalParameters[i]).Clone();
            }

            return clonedParameters;
        }

        #endregion private methods, variables, and constructors

        #region caching functions

        /// <summary>
        /// 缓存参数数组
        /// </summary>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <param name="commandParameters">SqlParamters数组 to be cached</param>
        public static void CacheParameterSet(string connectionString, string commandText, params SqlParameter[] commandParameters)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (commandText == null || commandText.Length == 0) throw new ArgumentNullException("commandText");

            string hashKey = connectionString + ":" + commandText;

            paramCache[hashKey] = commandParameters;
        }

        /// <summary>
        /// 从缓存获取SqlCommand数组
        /// </summary>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="commandText">存储过程的名字或sql命令</param>
        /// <returns>SqlParamters数组</returns>
        public static SqlParameter[] GetCachedParameterSet(string connectionString, string commandText)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (commandText == null || commandText.Length == 0) throw new ArgumentNullException("commandText");

            string hashKey = connectionString + ":" + commandText;

            SqlParameter[] cachedParameters = paramCache[hashKey] as SqlParameter[];
            if (cachedParameters == null)
            {
                return null;
            }
            else
            {
                return CloneParameters(cachedParameters);
            }
        }

        #endregion caching functions

        #region Parameter Discovery Functions

        /// <summary>
        /// 取出存储过程的参数集
        /// </summary>
        /// <remarks>
        /// 查询数据库,并取出存储过程的参数集缓存起来
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <returns>SqlParamters数组</returns>
        public static SqlParameter[] GetSpParameterSet(string connectionString, string spName)
        {
            return GetSpParameterSet(connectionString, spName, false);
        }

        /// <summary>
        /// 取出存储过程的参数集
        /// </summary>
        /// <remarks>
        /// 查询数据库,并取出存储过程的参数集缓存起来
        /// </remarks>
        /// <param name="connectionString">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="includeReturnValueParameter">A bool value indicating whether the return value parameter should be included in the results</param>
        /// <returns>SqlParamters数组</returns>
        public static SqlParameter[] GetSpParameterSet(string connectionString, string spName, bool includeReturnValueParameter)
        {
            if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                return GetSpParameterSetInternal(connection, spName, includeReturnValueParameter);
            }
        }

        /// <summary>
        /// 取出存储过程的参数集
        /// </summary>
        /// <remarks>
        /// 查询数据库,并取出存储过程的参数集缓存起来
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <returns>SqlParamters数组</returns>
        internal static SqlParameter[] GetSpParameterSet(SqlConnection connection, string spName)
        {
            return GetSpParameterSet(connection, spName, false);
        }

        /// <summary>
        /// 取出存储过程的参数集
        /// </summary>
        /// <remarks>
        /// 查询数据库,并取出存储过程的参数集缓存起来
        /// </remarks>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="includeReturnValueParameter">是否包含返回值参数</param>
        /// <returns>SqlParamters数组</returns>
        internal static SqlParameter[] GetSpParameterSet(SqlConnection connection, string spName, bool includeReturnValueParameter)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            using (SqlConnection clonedConnection = (SqlConnection)((ICloneable)connection).Clone())
            {
                return GetSpParameterSetInternal(clonedConnection, spName, includeReturnValueParameter);
            }
        }

        /// <summary>
        /// 取出存储过程的参数集
        /// </summary>
        /// <param name="connection">合法的连接</param>
        /// <param name="spName">存储过程的名字</param>
        /// <param name="includeReturnValueParameter">A bool value indicating whether the return value parameter should be included in the results</param>
        /// <returns>SqlParamters数组</returns>
        private static SqlParameter[] GetSpParameterSetInternal(SqlConnection connection, string spName, bool includeReturnValueParameter)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (spName == null || spName.Length == 0) throw new ArgumentNullException("spName");

            string hashKey = connection.ConnectionString + ":" + spName + (includeReturnValueParameter   ":include ReturnValue Parameter" : "");

            SqlParameter[] cachedParameters;

            cachedParameters = paramCache[hashKey] as SqlParameter[];
            if (cachedParameters == null)
            {
                SqlParameter[] spParameters = DiscoverSpParameterSet(connection, spName, includeReturnValueParameter);
                paramCache[hashKey] = spParameters;
                cachedParameters = spParameters;
            }

            return CloneParameters(cachedParameters);
        }

        #endregion Parameter Discovery Functions

    }
}


以上是sqlhelper.cs代码,下面有下载

在web.config中 加入


 <appSettings>
    <!-- 连接字符串是否加密 -->
    <add key="ConStringEncrypt" value="false"/>
    <!-- 数据库连接字符串,(如果采用加密方式,上面一项要设置为true;加密工具,可在官方下载,
     		如果使用明文这样server=127.0.0.1;database=.....,上面则设置为false。 -->
    <add key="ConnectionString" value="server=127.0.0.1;database=acrossdb1;uid=sa;pwd=123456"/>
    <!--其它模块连接字符串,可以不断增加以便同一个项目支持连接多个数据库。如果没有,可以删除该行-->
    <add key="ConnectionString2" value="server=127.0.0.1;database=acrossdb2;uid=sa;pwd=123456"/>
    <!--虚拟目录名称(如果是站点,则为空) -->
    <add key="VirtualPath" value=""/>
    <!--登录页地址 -->
    <add key="LoginPage" value="admin/Login.aspx"/>
    <!--默认菜单是否是展开状态-->
    <add key="MenuExpanded" value="false"/>
    <!--实体对象内容缓村的时间(分钟)-->
    <add key="ModelCache" value="30"/>
  </appSettings>

(英文转载)最热门的HTML5教程

Most Wanted HTML 5 Tutorials

Posted by Jillz on January 18th, 2010

 

原文地址:http://smashingwebs.com/ p=217

 

 

We just got some fabulous CSS3 tutorials.. Now all you need is to have some HTML 5 Tutorials. HTML 5 is the most modern version of Html that you must learn. So here I have them for you guys.. :) I hope this will help you to understand more. Your comments are very essential for my improvement. So Kindly do comment here.

1. Create a simple web page layout with HTML 5!

2. HTML 5 Visual Cheat Sheet by Woork

3. Web Designers’ Browser Support Checklist

4. webOS HTML5 Database Storage Tutorial

5. HTML5 Doctor, helping you implement HTML5 today

6. Rounded corners on HTML 5 elements

7. Designing a Blog with HTML5

8. HTML 5 Cheat Sheet

9. Designing a Blog with HTML 5

10. Coding an HTML 5 Layout From Scratch

11. Preparing for HTML 5 with Semantic Class Names

12. HTML 5: Nav Ambiguity Resolved

13.  A Basic HTML 5 Tutorial To Show Simple Page Structure

14. HTML 5 Visual Cheat Sheet by Woork

15. HTML 5 Pocket Book

You can also suggest some nice HTML 5 tutorials if you have some. Lets make it large :)