Socut.Data.dll 與AspNetPager.dll
使用說明及心得體會(huì)
以前,我是做Java項(xiàng)目的,最近接了的個(gè)項(xiàng)目,客戶要求使用.net來做,只有一個(gè)月的工期。為了能減少學(xué)習(xí)鉆研時(shí)間,我選擇了Socut.Data.dll做為數(shù)據(jù)庫訪問控件,AspNetPager.dll為分頁控件。這樣我在技術(shù)上的主要障外就基本解除了。下面我對(duì)該項(xiàng)目使用這2個(gè)控件的一些方法與心得體會(huì)。
一、?控件下載地址: 1、Socut.Data.dll:
http://data.socut.com/
2、AspNetPager.dll:
http://www.webdiyer.com/AspNetPager/default.aspx
二、?使用說明
1、?Socut.Data.dll連接配置
在web.config配置加入如下配置項(xiàng):
<appSettings>
??? <!--***************** 數(shù)據(jù)庫的設(shè)置 *****************
?!- SocutDataLink:? 數(shù)據(jù)庫鏈接參數(shù)(自動(dòng)判斷類型)
?!- Access類型:???? /所在目錄/數(shù)據(jù)庫名.mdb
?!- SQL Server類型: uid=賬號(hào);pwd=密碼;database=數(shù)據(jù)庫;server=服務(wù)器
**************************************************-->
<add key="SocutDataLink" value="server =192.168.1.100\OASIS_ZT25J;uid=dev;pwd=mypassword;database=XXXOA"/>
我使用的是SQLSERVER2005O數(shù)據(jù)庫。
??? <!--***************** 組件授權(quán)碼 *****************
?!- SocutDataKey:?? 系統(tǒng)授權(quán)碼(自動(dòng)判斷域名)
**************************************************-->
??? <add key="SocutDataKey" value="nZoxnwHIL2e/4pDU6/4JNg=="/>
??? <!--**********************************************-->
? </appSettings>
? 我使用的是3.0版本,需要組件授權(quán)碼,可到
<http://data.socut.com/default.aspx?go=reg>
獲取。
2、?控件加載
Socut.Data.dll與AspNetPager.dll的加載到項(xiàng)目的方法是一樣的,就是在Microsoft Visual Studio 2005的工具欄中右鍵菜單中選擇“選擇項(xiàng)…”,彈出窗口,再瀏覽找到控加入即可。
三、?過程體會(huì)
使用Socut.Data.dll最大的好處就是訪問操作數(shù)據(jù)庫非常方便,與AspNetPager.dll結(jié)合,我采用repeater控件作為數(shù)據(jù)列表顯示,界面設(shè)計(jì)簡單。
這里
http://data.socut.com/default.aspx?go=video
有這兩個(gè)控使用的視頻教程,做得簡單明了,一看就懂,非常感謝作者的用心良若。
下面看下我的數(shù)據(jù)顯示代碼:
?? 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();
??? }
當(dāng)然,查詢條件里我是在客戶端做了文本特殊字符錄入限制了的,不然的話會(huì)有問題。最好是能使用傳參數(shù)的方法了,有待改進(jìn)。從Socut.Data.ExecuteDataSet的傳入?yún)?shù)來看,她應(yīng)該是只返回指定行數(shù)的記錄到緩存中,而不是把所有記錄都取過來。這樣可以提高效率,并減輕Web服務(wù)器的負(fù)擔(dān)。
四、?改進(jìn)建議
我使用過程中,發(fā)現(xiàn)Socut.Data.dll里為了提高數(shù)據(jù)庫訪問速度,肯定是使用了緩存技術(shù)。但某些應(yīng)用我更新了數(shù)據(jù)庫,同時(shí)馬上就要取出更新的值卻取不到。還希望能有個(gè)較好的解決辦法。最好是可以設(shè)置某次訪問操作不用緩存。
轉(zhuǎn)載自: http://www.cnblogs.com/lojxg/archive/2007/10/26/938322.html
?
前幾天我還在使用GridView自帶的分頁,后來朋友給我說了這個(gè),嘿!超級(jí)好用!雖然別的地方也有,但是我還是想把它分享給大家,
下載地址 : http://www.webdiyer.com/Products/AspNetPager/Downloads
AspNetPager分頁示例: http://www.webdiyer.com/AspNetPagerDemo/ApplyStyles/default.aspx
下載后把控件拉進(jìn)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);?? /***主要的步驟在這里,調(diào)用下面的方法***/
??????? 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;
??? }
你只要把代碼中和數(shù)據(jù)庫交互的地方換成你自己的,那就OK啦!試試吧!
轉(zhuǎn)載:http://www.cnblogs.com/elgt/archive/2009/12/26/1632872.html
http://www.webdiyer.com/AspNetPagerDemo/ApplyStyles/default.aspx
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
