心情好,散点源代码玩

xhan2000 2003-07-25 11:39:14
1、大数据量分页

public IDataReader GetCurrentDataReader(string tableName,string columns,string PK,int pageSize,int currentPageIndex,string condition,bool desc)
{
this.Mycomm_Init();//初始化
this.reader_Close();//先关闭
string sql;
if(desc)
{
sql="select "+columns+" from "+tableName+" where "+PK+" in (select top "+pageSize.ToString()+" "+PK+" from "+tableName+" where "+PK+" in(select top "+(pageSize*(currentPageIndex+1)).ToString()+" "+PK+" from "+tableName+" where "+condition+" order by "+PK+" Desc) order by "+PK+") order by "+PK+" Desc";
}
else
{
sql="select "+columns+" from "+tableName+" where "+PK+" in (select top "+pageSize.ToString()+" "+PK+" from "+tableName+" where "+PK+" in(select top "+(pageSize*(currentPageIndex+1)).ToString()+" "+PK+" from "+tableName+" where "+condition+" order by "+PK+") order by "+PK+" desc) order by "+PK;
}
this.Mycomm.CommandText=sql;
this.Myconn_Open();//打开连接
this.reader=this.Mycomm.ExecuteReader();
return this.reader;
}



2、HashTable在ADO.NET的巧妙使用方法
public virtual bool TableRow_Add(Hashtable ht,string table_name)
{
ClearTable(table_name);//确保不存在table_name
this.Mya_Build("select * from "+table_name+" where 1=2", table_name);//构造DataAdapter(mya)和填充DataSet(ds)
DataRow Mydr= this.ds.Tables[table_name].NewRow();
IDictionaryEnumerator Mycollection = ht.GetEnumerator();
while(Mycollection.MoveNext())
{
Mydr[Mycollection.Key.ToString()] = MyStr.GetDBValue(Mycollection.Value);
}
this.ds.Tables[table_name].Rows.Add(Mydr);
mya.Update(ds,table_name);
return true;
}

感兴趣的朋友可以根据这个做出TableRow_Update


使用的时候很简单
Hashtable ht=new Hashtable();
ht.Add("FirstName","xhan");
ht.Add("FirstName","2000");
ht.Add("Photo",MyByte);//图片也可
TableRow_Add(ht,"Employees");
特别适合多层开发

牵扯到事务的话,可以继承ServicedComponent,使用自动事务


这两个东西我在很多项目使用,可提高开发效率,有什么问题可以联系我
...全文
38 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
hunter4500 2004-03-21
  • 打赏
  • 举报
回复
up!
yangnajianmin 2003-12-19
  • 打赏
  • 举报
回复
xieixe
yshawxp 2003-12-09
  • 打赏
  • 举报
回复
谢谢
NetAnt007 2003-11-29
  • 打赏
  • 举报
回复
好人一生平安
lucidaxy 2003-09-28
  • 打赏
  • 举报
回复
好,楼主真是好人
seakingii 2003-09-09
  • 打赏
  • 举报
回复
有没有windows20003的原码?
jianglinchun 2003-09-08
  • 打赏
  • 举报
回复
我顶,藏着先了。
chinawn 2003-09-05
  • 打赏
  • 举报
回复
收藏
91大白兔奶糖 2003-08-04
  • 打赏
  • 举报
回复
收藏
xhan2000 2003-08-02
  • 打赏
  • 举报
回复
呵呵

这个就是c#的东西。编译成程序集,其他语言可方便调用
mengqifeng 2003-08-01
  • 打赏
  • 举报
回复
先收藏
laogao 2003-08-01
  • 打赏
  • 举报
回复
我怎么觉得我C#程序一样啊.

1,978

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧