C#教程 【C#源码】查询OLEDB指定表的所有字段
珍惜源码,传播留址 [v_notice]引用命名空间 using System.Collections.Generic; using System.Data; using System.Data.OleDb; using System.Text; [/v_notice] public List<string> GetList(string tn) { DataTable table = dbcon.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, null, null }); List<string> ts = new List<string>(); foreach (DataRow row in table.Rows) { if(row[“TABLE_NAME”].ToString()==tn) ts.Add(row[“COLUMN_NAME”].ToString()); } return ts; } 测试运行 查询结果:{ID,测试1,测试2,}
1,146 Views
0 Comments
C#教程 2019-05-01