作者:铁拳
来源:hiDotNet.com
相关:http://blog.csdn.net/Sun_Jianhua/archive/2004/07/04/33574.aspx
[url=http://bbs.hidotnet.com/PostAttachment.aspx?PostID=14250&AttachmentID=452]C# 示例源代码[/url]
[code=sql]/*
经测试,在 14483461 条记录中查询第 100000 页,每页 10 条记录按升序和降序第一次时间均为 0.47 秒,第二次时间均为 0.43 秒,测试语法如下:
exec GetRecordFromPage news,newsid,10,100000
news 为 表名, newsid 为关键字段, 使用时请先对 newsid 建立索引。
*/
/*
函数名称: GetRecordFromPage
函数功能: 获取指定页的数据
参数说明: @tblName 包含数据的表名
@fldName 关键字段名
@PageSize 每页记录数
@PageIndex 要获取的页码
@OrderType 排序类型, 0 – 升序, 1 – 降序
@strWhere 查询条件 (注意: 不要加 where)
作 者: 铁拳
邮 箱: sunjianhua_kki@sina.com
创建时间: 2004-07-04
修改时间: 2004-07-04
*/
CREATE PROCEDURE GetRecordFromPage
@tblName varchar(255), — 表名
@fldName varchar(255), — 字段名
@PageSize int = 10, — 页尺寸
@PageIndex int = 1, — 页码
@OrderType bit = 0, — 设置排序类型, 非 0 值则降序
@strWhere varchar(2000) = ” — 查询条件 (注意: 不要加 where)
AS
declare @strSQL varchar(6000) — 主语句
declare @strTmp varchar(1000) — 临时变量
declare @strOrder varchar(500) — 排序类型
if @OrderType != 0
begin
set @strTmp = ‘<(select min'
set @strOrder = ' order by [' + @fldName + '] desc'
end
else
begin
set @strTmp = '>(select max’
set @strOrder = ‘ order by [‘ + @fldName +’] asc’
end
set @strSQL = ‘select top ‘ + str(@PageSize) + ‘ * from [‘
+ @tblName + ‘] where [‘ + @fldName + ‘]’ + @strTmp + ‘([‘
+ @fldName + ‘]) from (select top ‘ + str((@PageIndex-1)*@PageSize) + ‘ [‘
+ @fldName + ‘] from [‘ + @tblName + ‘]’ + @strOrder + ‘) as tblTmp)’
+ @strOrder
if @strWhere != ”
set @strSQL = ‘select top ‘ + str(@PageSize) + ‘ * from [‘
+ @tblName + ‘] where [‘ + @fldName + ‘]’ + @strTmp + ‘([‘
+ @fldName + ‘]) from (select top ‘ + str((@PageIndex-1)*@PageSize) + ‘ [‘
+ @fldName + ‘] from [‘ + @tblName + ‘] where ‘ + @strWhere + ‘ ‘
+ @strOrder + ‘) as tblTmp) and ‘ + @strWhere + ‘ ‘ + @strOrder
if @PageIndex = 1
begin
set @strTmp = ”
if @strWhere != ”
set @strTmp = ‘ where (‘ + @strWhere + ‘)’
set @strSQL = ‘select top ‘ + str(@PageSize) + ‘ * from [‘
+ @tblName + ‘]’ + @strTmp + ‘ ‘ + @strOrder
end
exec (@strSQL)
GO[/code]
示例截图

IBM笔记本安装无线网卡
在IBM笔记本上安装无线网卡是需要破解的。适合机型:T30以后的IBM笔记本电脑。怎么破解?叫1802破解。下载一个破解文件,需要在DOS下破解。1802并非单只针对硬件上的,如无线网卡。开机BIOS报错1802和这个软件上的1802有所区别。网络上流传的4张盘的恢复盘一般只是一个型号,例如从T40 G1C抽出来的。虽然应用在大部分的T40/T41机器都通用,但是如果硬件改动太大,会出现无法安装的问题。又或者安装到了,windows也可能要重新激活。 破解1802,具体过程是这样的 下载http://www.everdigi.com/upfiles/1802.rar,解压后是个ISO,那个ISO用虚拟光驱或WINRAR打开可以看到里面有一个文件夹和一个文件, 都与蓝牙有关, 可以不去理睬,真正的破解文件是看不到的. 那个ISO本身就是一个自启动光盘镜象,所以不需要再重新做启动光盘. 操作步骤: 1.下载ISO文件到硬盘 2.我用NERO BURNING 里的\”刻录镜象文件到光盘…..\”(选项名不记得了, 差不多就这个吧)选择那个ISO文件, 把一张新刻录碟放入刻录机, 直接点\”确认\”. 3.刻完后, 请检查一下光盘中是否有那2个跟蓝牙有关的文件,(这是怕你的刻录机有问题,我就碰到个有问题的刻录机,刻出来的都是空盘,放到机器里一点反映都没) 4.调整你的本本到光盘启动, 放入光盘,启动机器一次, 然后会出现以下DOS画面(大致上) ***************************************** CTRL+ALT+DEL重启动 ***************************************** A:>光标闪烁 这时已经破解成功了, 拿出光盘, CTRL+ALT+DEL重启动电脑,就OK了.
Gallery Feature
Bar Graph column in a sorted datagrid
[align=center]
[/align]
[b][color=Orange]Introduction[/color][/b]
Hi, this is my first attempt at an article for CodeProject. I’ve used enough of other peoples so thought I better give something back. I’ve been developing websites for the last 6 years or so doing everything from PHP to C#.NET. For other examples please visit the development section on http://www.chemlock.co.uk/. The project below is ASP.NET in C#. There was a need to display a simple bar per row in the datagrid to quickly illustrate an amount. This is very simple so I’ve set it to beginner level. Any questions please mail me.
[b]Graph display in datagrids[/b]
This morning I had the pleasure of re-writing a consultants code into something which worked and was open to development. For some strange reason this guy wrote all his code in classic ASP hard coding the database connection strings into a file and creating all the SQL on the fly. This was slow. Not only because it was Classic ASP and the SQL strings were constantly changing so the server couldn’t cache the query but because it was badly written. One page got passed two variables in the http request stream and then used those variables to pull the same two values back from the database. Pointless and time consuming. Anyway the results where thrown into tables and one column on all the tables was a graph to show the amount of time booked to a project per week. This was out of a maximum of 60 hours (Don’t know which fool is doing those hours). My friend the highly paid consultant had done this by making a table within a table cell with a width equal to the amount of hours. This meant that if you have booked 34 hours to a project the graph would be 34 pixels long.
I was asked to fix some of the SQL as the results where not very relevant for one of the reports but thought it would be a fairly quick and simple job to simply move the lot to .Net and Stored Procs. So here is my quick and dirty guide to creating a graph column in a datagrid. It’s all nice and basic(C# actually), certainly not rocket science.
First of all Create a nice clean WebForm Here is the code behind.
[code=c#]private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
if(Request[”EmployeeNo”] != null)
{
Db db = new Db();
ArrayList parameters = new ArrayList();
parameters.Add(new DbParameter(”@EmployeeNo”,DbType.String,10,”EmployeeNo”,Request[”EmployeeNo”].ToString()));
Session[”dataset”] = db.GetDataSet(”GetEmployeeBookings”,parameters);
Session[”SortOn”] = “EndDate”;
Session[”SortDirection”] = ” DESC”;
}
}
BindGrid();
} [/code]
Ok so here notice that I’m using a class called DB to get at my database and create a dataset. Use what you like here the main point is to end up with a dataset of your results. I also set up initial Sort Parameters for my datagrid and the initial direction they will be sorted in. Every post back gets the grid bound with data but only the initial pass gets the data from the Database. Obviously if this data was likely to be changed as a result of any page action I would move this database call to a seperate methods but as it’s a static report and I’m in a hurry I’ve left it as I initially did it.
[code=c#]private void BindGrid()
{
if (Session[”dataset”] != null)
{
DataTable dt = ((DataSet)Session[”dataset”]).Tables[0];
DataView dv = dt.DefaultView;
dv.Sort = Session[”SortOn”].ToString() + Session[”SortDirection”].ToString();
this.DataGrid1.DataSource = dv;
this.DataGrid1.DataBind();
} [/code]
Here is the BindGrid method. It first checks that something exists in the Session variable. If it does it extracts it creates a dataview sorted correctly and then binds that to our DataGrid control. Notice how very lazy I’ve been with my DataGrid naming. Remeber this was quick and dirty.
[code=c#]private void DataGrid1_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
Session[”SortOn”] = e.SortExpression.ToString();
if (Session[”SortDirection”] == null || Session[”SortDirection”].ToString() == ” ASC”)
{
Session[”SortDirection”] = ” DESC”;
}
else
{
Session[”SortDirection”] = ” ASC”;
}
this.DataGrid1.CurrentPageIndex = 0;
BindGrid();
} [/code]
Here is a nice and standard Sort Event Method. Basically if you select a column heading that has already been selected it will change the direction of that column. Any other column and the grid gets sorted on the new column heading.
[code=c#]private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
decimal hours = decimal.Parse(e.Item.Cells[3].Text);
decimal percentage = (100m / 60m) * hours;
e.Item.Cells[4].Text = “
“;}
} [/code]
This is where the graph is built. In my on-going quest to get shot of tables where tables shouldn’t be I’ve gone for a “DIV” approach. Firstly I create a div that fills the entire cell. Then inside this I create a div that takes up a percentage of the parent div. Please note that without the height command the graph will not show in Firefox. So I’ve got my 60 hours and then work out a percentage of this for the width of the child div. The code is set to apply this when each line of the datagrid gets databound. Each time the hours is worked out from another column in the database (In this instance column 3) and Parsed to a decimal. The resultant html code is injected into the cell 4. All this is set to only occur when the datagrid item (or row) is an Item or Alternating item type, after all we don’t want to create a graph for the header or pager section.
So there we have it very quick and very dirty but it does the trick.
As I said at the start fairly simple, if my description has complicated things then please let me know. Other examples on www.chemlock.co.uk
论文once more??
在论文答辩结束近一周后,收到一封邮件
[quote]格式还要按此修改,我明天集中时间会说的
> >
> > 信息学院本次本科毕业论文的格式以此为准,这是最后的版本,带来的不便请大家谅解![/quote]
我只想说两个字:
[b]我日[/b] !8o|
Wireless LAN 一期失败
今天去垃圾街把Buffalo WBR-G54 Wireless Router请回了家,踌躇满志的要组自己的无线局域网。
当一切设置完毕,本本也发现了无线讯号,连接的时候却蓝屏了!!
天哪!!真的是好几年没看到的蓝屏!!连续重启了好几次,都是蓝屏。
绝望!
只能关掉Router 的wireless,改用网线连接。
哎。好端端的一个无线路由,现在只能当普通路由来用了。。。
过两天把小黑的MINIPCI网卡给换掉,到时候再试试了。
SIGH…
I'm Testing AutoSave!
I’m Testing AutoSave!
75 is saved at Thu Jun 01 17:47:41 2006
Javascript时间按钮
ByeBye论文!!
总算和论文说拜拜。
今天下午的答辩真的是变态,跑过去竟然告诉我们办公室里的电脑不能用,要演示的话必须自己带笔记本。NND!还得我空着肚子跑回寝室把小黑抱了过去才解了燃眉之急。
答辩的时候被问了几个变态的问题,比如:
答辩老师:你用这两种算法作了10个东西,我觉得你如果能把其中的一个做做好,演示清楚已经挺不错了。
我:额。。。这个。。。其实理论上是这样子的,但是这个论文的题目不是我选的,我还把不得能少做几个呢。。。
答辩老师:^&#&*%&^%
答辩老师:对于一个搜索问题,如果把一个问题分成两个子问题,它的搜索复杂度和原问题相比,是多还是少了?或者没有改变?
我:如果是分成两半,那么应该是少了,因为对半搜索可以把问题的规模缩小一半。
答辩老师:我没问你对半搜索!我说的是把一个问题分成两个子问题,不是说把一个问题分成两半,再取其中的一个子问题!
我:这个。。。这两个说法有区别吗?
答辩老师:我说的是把一个问题分成两个子问题!!
我:那。。。应该是没有改变吧?
答辩老师:对阿!你早这样说不就好了吗?
我:如果对搜索复杂度没有改善,那为什么要这样子把问题分割开来?
答辩老师:&^*&%(**$&
不过还好我的导师柳老师一直在边上帮我打圆场,答辩能够顺利完成,真的要好好感谢她。:)
24Hours Season5 Episode24
刚刚看完24小时第五季的最后一集。
总的来说这一季比较令人失望,剧情拖沓,而且没有很多出乎意料的东西。
不过最后一集还是设计的比较巧妙的,比如Jack审判Charles,本来以为Jack会给Charles一个子弹吃吃,然后Charles就老老实实招供了,没想到Jack竟然被捕了。又以为在机场的机库里,Martha身上肯定会带偷听器,没想到最后竟然是Charles自己身上被作了手脚(应该是Jack审判他的时候干的)。又以为总算Jack和Audrey可以团圆了,没想到又横生枝节。。。
为什么不能每一集都像最后一集这样编剧呢?
最后24小时还是留下了不少悬念。
首先是Secretary Heller的生死,我是觉得这样一个角色不应该不明不白的就坠河死了,很有可能在Season6里就莫名其妙的再次出现,解释可能是被村民所救保得姓名?(lol)
其次是Charles的同谋,本季内没有交代,但是听他们的口音,我估计是英国人,也许是军情五处的人。呵呵。纯粹瞎猜了。
最后就是Jack的命运。本季最后暗示了Jack被带上了开往中国的货轮(好像还是上海籍的),相信Season6会有不少剧情与中国有关,值得期待。