Socut.Data.dll 与AspNetPager.dll

一、 控件下载地址:
1、Socut.Data.dll:http://data.socut.com/
2、AspNetPager.dll:http://www.webdiyer.com/AspNetPager/default.aspx
二、 使用说明
1、 Socut.Data.dll连接配置
在web.config配置加入如下配置项:
<appSettings>
    <!--***************** 数据库的设置 *****************
!— SocutDataLink:  数据库链接参数(自动判断类型)
!— Access类型:    /所在目录/数据库名.mdb
!— SQL Server类型: uid=账号;pwd=密码;database=数据库;server=服务器
**************************************************-->
<add key="SocutDataLink" value="server =172.18.188.1\OASIS_ZT25J;uid=dev;pwd=mypassword;database=XXXOA"/>
我使用的是SQLSERVER2005O数据库。
    <!--***************** 组件授权码 *****************
!— SocutDataKey:  系统授权码(自动判断域名)
**************************************************-->
    <add key="SocutDataKey" value="nZoxnwHIL2e/4pDU6/4JNg=="/>
    <!--**********************************************-->
  </appSettings>
  我使用的是3.0版本,需要组件授权码,可到http://data.socut.com/default.aspx?go=reg获取。
2、 控件加载
Socut.Data.dll与AspNetPager.dll的加载到项目的方法是一样的,就是在Microsoft Visual Studio 2005的工具栏中右键菜单中选择“选择项…”,弹出窗口,再浏览找到控加入即可。

三、 过程体会
使用Socut.Data.dll最大的好处就是访问操作数据库非常方便,与AspNetPager.dll结合,我采用repeater控件作为数据列表显示,界面设计简单。
这里http://data.socut.com/default.aspx?go=video有这两个控使用的视频教程,做得简单明了,一看就懂,非常感谢作者的用心良若。
下面看下我的数据显示代码:
  protected void ShowGrid()
    { //查询条件变量赋值
        sqlwhere = " where isnull(cName,'') like '%" + cName.Text + "%' and isnull(cValue1,'') like '%" + cValue1.Text + "%'  and isnull(cValue2,'') like '%" +cValue2.Text + "%'";
        AspNetPager1.RecordCount = (int)Socut.Data.ExecuteScalar("select count(*) from dconst  " + sqlwhere);
        DataSet ds = Socut.Data.ExecuteDataSet("select * from dconst " + sqlwhere+ "order by cName,cSerial",
            AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize);
        //用repeater
        Repeater1.DataSource = ds;
        Repeater1.DataBind();
    }
当然,查询条件里我是在客户端做了文本特殊字符录入限制了的,不然的话会有问题。最好是能使用传参数的方法了,有待改进。从Socut.Data.ExecuteDataSet的传入参数来看,她应该是只返回指定行数的记录到缓存中,而不是把所有记录都取过来。这样可以提高效率,并减轻Web服务器的负担。

你可能感兴趣的:(PAGER)