DbUtility-查询DataTable
时间:2014-05-01 21:15:43
收藏:0
阅读:560
直接上源码
1 using System; 2 using System.Data; 3 using System.Threading.Tasks; 4 using DbUtility; 5 6 namespace TestDbUtilityConsole 7 { 8 class Program 9 { 10 static SqlDbUtility db = new SqlDbUtility("Data Source=(local);Initial Catalog=ReportServer;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False"); 11 static void Main(string[] args) 12 { 13 DataTable dt = GetDataTable().Result; 14 Console.WriteLine(dt.Rows.Count); 15 Console.ReadKey(); 16 } 17 18 static async Task<DataTable> GetDataTable() 19 { 20 DataTable dt = await db.T("select * from Roles").ExecuteDataTableAsync(); 21 return dt; 22 } 23 } 24 }
结果:8
开发工具:VS2012
组件:ReSharper8.0.2
数据库:SQL Server 2008 R2 默认安装的数据库ReportServer
评论(0)