DbUtility-查询DataTable

时间:2014-05-01 21:15:43   收藏:0   阅读:560

直接上源码

mamicode.com,码迷
 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 }
mamicode.com,码迷

结果:8

开发工具:VS2012

组件:ReSharper8.0.2

数据库:SQL Server 2008 R2 默认安装的数据库ReportServer

DbUtility-查询DataTable,码迷,mamicode.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!