一、填充dataset

 1  class Program
 2     {
 3         private static string constr = "server=.;database=northwnd;integrated security=sspi";
 4         static void Main(string[] args)
 5         {
 6             string sql = "select contactname,companyname from customers";
 7             using (SqlConnection con=new SqlConnection(constr))
 8             {
 9                 SqlDataAdapter sda = new SqlDataAdapter(sql, constr);
10                 DataSet ds = new DataSet();
11                 sda.Fill(ds, "Customers");
12                 foreach (DataRow row in ds.Tables["Customers"].Rows)
13                     Console.WriteLine("'{0}' from {1}",
14                         row[0],
15                         row[1]);
16 
17                 con.Close();
18             }
19             Console.ReadLine();
20         } 
21     }
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2021-05-27
  • 2021-09-21
  • 2021-07-09
  • 2021-07-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2021-12-06
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案