首页 > 其他 > 详细

DataSet读取数据

时间:2014-03-03 16:31:31      阅读:398      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
 1 using System.Data;
 2 using System.Data.SqlClient;
 3 
 4 namespace ConsoleApplication3
 5 {
 6     class Program
 7     {
 8         static void Main(string[] args)
 9         {
10             SqlConnection thisConn = new SqlConnection(@"Server=.\Nie;uid=sa;pwd=111;Database=MyNorthwind");
11 
12 
13             SqlDataAdapter thisAdapter = new SqlDataAdapter("select customerId,Address from Customers",
14                                                              thisConn);
15             DataSet thisDataSet = new DataSet();
16             thisAdapter.Fill(thisDataSet, "customers");
17             foreach (DataRow theRow in thisDataSet.Tables["Customers"].Rows)
18             {
19                 Console.WriteLine(theRow["customerId"] + "\t" + theRow["Address"]);
20             }
21             thisConn.Close();
22             Console.Write("Program finished,press any key to Continue.");
23             Console.ReadLine();
24 
25         }
26     }
27 }
bubuko.com,布布扣

DataSet读取数据,布布扣,bubuko.com

DataSet读取数据

原文:http://www.cnblogs.com/ByBull/p/3577369.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!