导航

2011年4月9日

摘要: 使用以下方法可以准确的记录代码运行的耗时。 System.Diagnostics.Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // 开始监视代码运行时间 // you code .... stopwatch.Stop(); // 停止监视 TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间 double hours = timespan.TotalHours; // 总小时 double minutes = timespan.Tota 阅读全文

posted @ 2011-04-09 21:39 beeone 阅读(1279) 评论(0) 推荐(1) 编辑

摘要: private void MakeDataTableAndDisplay(){ // Create new DataTable. DataTable myDataTable = new DataTable("MyDataTable"); // Declare DataColumn and DataRow variables. DataColumn myDataColumn; DataRow myDataRow; // Create new DataColumn, set DataType, ColumnName and add to DataTable. myDataCol 阅读全文

posted @ 2011-04-09 21:22 beeone 阅读(3535) 评论(0) 推荐(0) 编辑

摘要: 要过滤与排序DataTable对象中的DataRow,用DataTable的Select()方法,Select()方法调用:DataRow[] Select()DataRow[] Select(string filterExpression)DataRow[] Select(string filterExpression,string sortExpression)DataRow[] Select(string filterExpression,string SortExpression,DataViewRowState myDataViewRowState)其中:filterExpressi 阅读全文

posted @ 2011-04-09 21:21 beeone 阅读(3475) 评论(0) 推荐(0) 编辑

摘要: DataTable排序的一般方法一、重生法dstaset.Tables.Add(dt)dataset.Tables(0).DefaultView.Sort = "id desc"--------------------------------------------------------------------------------二、直接法dv = New DataView(dt)dv.Sort = "id desc"------------------------------------------------------------------ 阅读全文

posted @ 2011-04-09 21:20 beeone 阅读(933) 评论(0) 推荐(0) 编辑

摘要: using System;using System.Data;namespace DataTable_Create{/// <summary>/// 使用DataTable实现内存表/// </summary>class T{ /// <summary> /// 使用DataTable实现内存表 /// </summary> private void CreateDataTable() { // 声明一个DataTable DataTable myDataTable = new DataTable("ParentTable") 阅读全文

posted @ 2011-04-09 21:20 beeone 阅读(1550) 评论(0) 推荐(0) 编辑

摘要: .C#中DataTable技术学习 2009-09-10 14:37:18 阅读1496 评论0 字号:大中小 订阅 .1.在DataTable中执行DataTable.Select("条件")返回DataTable;// <summary>// 执行DataTable中的查询返回新的DataTable// </summary>// dt 是源数据DataTable// condition 是查询条件DataTable newdt = new DataTable();newdt = dt.Clone(); // 克隆dt 的结构,包括所有 dt 架构 阅读全文

posted @ 2011-04-09 21:19 beeone 阅读(7562) 评论(0) 推荐(1) 编辑

摘要: 方法一:DataTable tblDatas = new DataTable("Datas");DataColumn dc = null;dc = tblDatas.Columns.Add("ID", Type.GetType("System.Int32"));dc.AutoIncrement = true;//自动增加dc.AutoIncrementSeed = 1;//起始为1dc.AutoIncrementStep = 1;//步长为1dc.AllowDBNull = false;//dc = tblDatas.Columns. 阅读全文

posted @ 2011-04-09 21:18 beeone 阅读(661) 评论(0) 推荐(0) 编辑

摘要: private void button1_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("c1"); dt.Columns.Add("c2"); dt.Columns.Add("c3"); dt.Columns.Add("c4"); dt.Columns.Add("c5"); dt.Columns.Add("c6"); dt.Columns.Add(&quo 阅读全文

posted @ 2011-04-09 21:17 beeone 阅读(239) 评论(0) 推荐(0) 编辑

摘要: 对于数据库的操作,资料太多,大家也比较熟悉。但有时数据量较少,但更新频繁的变量操作,通常采用自定义结构,但自定义结构的可维护性和灵活性就比不上临时表,我们可以先用DataTable做为内存临时表,以数据库操作的方式灵活添加列、行,完成 主键设置、查询、更新等操作,还可以保存为xml文件。假设在当前类作用域有全局对象public static DataTable dtRefresh = new DataTable();我们在某个测试函数中添加下面的测试代码:为了方便存储为xml文件,需要设置表名:dtRefresh.TableName = "刷新任务";为临时表添加表结构,既 阅读全文

posted @ 2011-04-09 21:16 beeone 阅读(846) 评论(0) 推荐(0) 编辑