您的位置:首页 > 编程语言 > ASP

Socut.Data.dll 与AspNetPager.dll使用说明及心得体会 (转载)

2010-08-17 14:20 225 查看
Socut.Data.dll 与AspNetPager.dll使用说明及心得体会
Socut.Data.dll 与AspNetPager.dll
使用说明及心得体会

以前,我是做Java项目的,最近接了的个项目,客户要求使用.net来做,只有一个月的工期。为了能减少学习钻研时间,我选择了Socut.Data.dll做为数据库访问控件,AspNetPager.dll为分页控件。这样我在技术上的主要障外就基本解除了。下面我对该项目使用这2个控件的一些方法与心得体会。
一、 控件下载地址: 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 =192.168.1.100\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服务器的负担。
四、 改进建议
我使用过程中,发现Socut.Data.dll里为了提高数据库访问速度,肯定是使用了缓存技术。但某些应用我更新了数据库,同时马上就要取出更新的值却取不到。还希望能有个较好的解决办法。最好是可以设置某次访问操作不用缓存。

转载自:/article/5509145.html

前几天我还在使用GridView自带的分页,后来朋友给我说了这个,嘿!超级好用!虽然别的地方也有,但是我还是想把它分享给大家,

下载地址:http://www.webdiyer.com/Products/AspNetPager/Downloads

AspNetPager分页示例:http://www.webdiyer.com/AspNetPagerDemo/ApplyStyles/default.aspx

下载后把控件拉进VS里就可以了,注意哦,VS2003是不可以用的!下面是代码:

protected void Pager1_PageChanged(object sender, EventArgs e)
{
OracleConnection objcon = this.getcon();
string querystr = "select * from stu";
OracleDataAdapter da = new OracleDataAdapter(querystr, objcon);
DataSet ds = new DataSet();
da.Fill(ds, "stu");
this.GridView1.DataSource = this.getPage(ds); /***主要的步骤在这里,调用下面的方法***/
this.GridView1.DataBind();
}

public PagedDataSource getPage(DataSet ds)
{
this.Pager1.RecordCount = ds.Tables[0].Rows.Count;
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.CurrentPageIndex = Pager1.CurrentPageIndex - 1;
pds.PageSize = Pager1.PageSize;
return pds;
}

你只要把代码中和数据库交互的地方换成你自己的,那就OK啦!试试吧!

转载:http://www.cnblogs.com/elgt/archive/2009/12/26/1632872.html

http://www.webdiyer.com/AspNetPagerDemo/ApplyStyles/default.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: