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里為了提高數據庫訪問速度,肯定是使用了緩存技術。但某些應用我更新了數據庫,同時馬上就要取出更新的值卻取不到。還希望能有個較好的解決辦法。最好是可以設置某次訪問操作不用緩存。
轉載自: http://www.cnblogs.com/lojxg/archive/2007/10/26/938322.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
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

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