datatable

EF扩展方法

为君一笑 提交于 2020-02-27 20:06:11
EF是微软提供的数据库ORM框架,集众家之所长,方便在Winform中使用,可以方便的转换成DataTable,代码如下: using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EF.Winfrom.Context { public static class EFExtendMethod { public static DataTable SqlQueryToDataTable(this Database db, string sql, CommandType type = CommandType.Text, params SqlParameter[] param) { DataTable ret_dt = new DataTable(); SqlConnection conn = db.Connection as SqlConnection; if (conn == null) { conn = new SqlConnection(db

C# CheckedListBox 中添加带 Text 和 Value 的 CheckBox

…衆ロ難τιáo~ 提交于 2020-02-27 06:30:09
首先从界面上添加CheckedListBox控件。 然后在代码中定义 DataTable,并和CheckedListBox 关联(CheckedListBox的名称为 receive): DataTabledataTable =newDataTable(); dataTable.Columns.Add("Text",typeof(string)); dataTable.Columns.Add("Value",typeof(string)); this.receive.DataSource = dataTable; this.receive.DisplayMember ="Text"; this.receive.ValueMember ="Value"; 向DataTable中加入DataRow对象: DataRowdataRow = dataTable.NewRow(); dataRow["Text"] = receive[1]; dataRow["Value"] = receive[0]; dataTable.Rows.Add(dataRow); 来源: oschina 链接: https://my.oschina.net/u/811698/blog/3161415

DataGridView分页功能的实现

拟墨画扇 提交于 2020-02-25 19:20:21
1 // 1、定义几个所需的公有成员: 2 3 int pageSize = 0; //每页显示行数 4 int nMax = 0; //总记录数 5 int pageCount = 0; //页数=总记录数/每页显示行数 6 int pageCurrent = 0; //当前页号 7 int nCurrent = 0; //当前记录行 8 DataSet ds = new DataSet(); 9 DataTable dtInfo = new DataTable(); 10 11 //2、在窗体载入事件中,从数据源读取记录到DataTable中: 12 13 string strConn = "SERVER=127.0.0.1;DATABASE=NORTHWIND;UID=SA;PWD=ULTRATEL"; //数据库连接字符串 14 SqlConnection conn = new SqlConnection(strConn); 15 conn.Open(); 16 string strSql = "SELECT * FROM CUSTOMERS"; 17 SqlDataAdapter sda = new SqlDataAdapter(strSql,conn); 18 sda.Fill(ds,"ds"); 19 conn.Close(); 20 dtInfo = ds

《Build the BookStore Application using the ABP vNext web application framework》笔记

社会主义新天地 提交于 2020-02-25 15:36:32
ABP core 的框架在过年期间,从1.0突然升级到2.0了,。 整个ABPCore 虽然版本变化 大,但使用流程基本不变吧, 我看官网上文档更新基本完毕了,官网文档有一个外国人视频,当时版本尚是0.18,总共有2小时吧。边看视频边记录个学习笔记吧! 这个 视频课程 被好心人转移到https://www.bilibili.comb , 视频和官方的 使用 ASP.NET Core MVC 入门教程的内容完全一致,而且官方教程似乎略有更新。 但看视频有个好处,就是不用自己敲代码调试了,有人演示给你看。 课程内容主要步骤记录: 【】所包含的是对应项目名 1、生成项目 abp new ,并编译全部 2、修改连接字符串: 【DbMigrator】修改连接字符串,并执行这个项目,就实现数据库的创建和写入种子数据. 这时可以启用【web】登录网站并修改密码 3、添加实体类,业务实体 【Domain】中添加Book, 继承自审计聚合根 auditedAggregateRoot类。 这个类本身实现了一系统接口 4、添加项目的全局的共有类 【domain.shared】中添加BookType的枚举类型。 它是整个解决方案共用的类型 5、在DBContext中注册实体类 【EFCore】中, DbContext中 添加DbSet<Book> books;

Editable Datatable RowKey Null

旧时模样 提交于 2020-02-24 11:22:06
问题 I have an editable Primefaces Datatable configured to call an onCellEdit() method when a cell is edited. Everything works great except that CellEditEvent.rowKey is always null in spite of setting it explicitly to a valid value in the Datatable declaration with 'rowKey='. The Primefaces Datatable documentation leads me to believe that I need the rowKey to get the contents of the row containing the cell being edited. I need the entire row's contents so I can compare the displayed data with the

How to add empty data row in Datatable using angular2+?

痞子三分冷 提交于 2020-02-22 05:31:52
问题 I want to add empty data row. My requirement is like columns are dynamic. I have tried using dtInstance to add the row. it's throwing some error. here is the link https://stackblitz.com/edit/how-to-replace-all-the-columns-dynamically-in-data-table-gvfose?file=app/app.component.ts Please let me know if more details required. 回答1: You gave the Data table wrong model. you are mixing between different models in your code. I've fixed it as well adding two empty rows, make sure to align with the

How to add empty data row in Datatable using angular2+?

十年热恋 提交于 2020-02-22 05:30:11
问题 I want to add empty data row. My requirement is like columns are dynamic. I have tried using dtInstance to add the row. it's throwing some error. here is the link https://stackblitz.com/edit/how-to-replace-all-the-columns-dynamically-in-data-table-gvfose?file=app/app.component.ts Please let me know if more details required. 回答1: You gave the Data table wrong model. you are mixing between different models in your code. I've fixed it as well adding two empty rows, make sure to align with the

JsonHelper

我是研究僧i 提交于 2020-02-17 18:39:38
Json对于一个开发者来说已经不陌生了,首先肯定要引用 Newtonsoft.Json ,对于开发者可以在NuGet包里面下载 也可以在下面链接下载 链接: https://pan.baidu.com/s/1yH5Yp2c9f73Bkx5bLiiiNQ 提取码: xi64 JsonHelper using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Web.Script.Serialization; namespace Common { public class JsonHelper { /// <summary> /// 实体转json /// </summary> /// <typeparam name="T">实体</typeparam> /// <param name="x">实体</param> /// <returns></returns> public static string EntityToJson<T>(T x) { string result = ""; try { result = JsonConvert.SerializeObject(x); }

How to remove DataColumn from DataTable programmatically

拥有回忆 提交于 2020-02-15 05:42:08
问题 I have a code foreach (DataColumn dataTableCol in this.dataTable.Columns) { bool columnFound = false; foreach (GRTColumnView uiColumn in descriptor.UIColumns) { if (dataTableCol.ColumnName.Equals(uiColumn.Name)) { columnFound = true; break; } } if (!columnFound) { if (this.dataTable.Columns.Contains(dataTableCol.ColumnName)) this.dataTable.Columns.Remove(dataTableCol.ColumnName); } } I want to remove some "things" from collection if they aren't found in another collection. When I run the

How to remove DataColumn from DataTable programmatically

喜你入骨 提交于 2020-02-15 05:40:12
问题 I have a code foreach (DataColumn dataTableCol in this.dataTable.Columns) { bool columnFound = false; foreach (GRTColumnView uiColumn in descriptor.UIColumns) { if (dataTableCol.ColumnName.Equals(uiColumn.Name)) { columnFound = true; break; } } if (!columnFound) { if (this.dataTable.Columns.Contains(dataTableCol.ColumnName)) this.dataTable.Columns.Remove(dataTableCol.ColumnName); } } I want to remove some "things" from collection if they aren't found in another collection. When I run the