dreader2.cs
Upload User: yiyuerguo
Upload Date: 2014-09-27
Package Size: 3781k
Code Size: 1k
Category:

CSharp

Development Platform:

Others

  1. using System;
  2. using System.Data;
  3. using System.Data.OleDb;
  4. namespace DataReader2App
  5. {
  6. /// <summary>
  7. /// Class1 的摘要说明。
  8. /// </summary>
  9. class DataReader2
  10. {
  11. /// <summary>
  12. /// 应用程序的主入口点。
  13. /// </summary>
  14. [STAThread]
  15. static void Main(string[] args)
  16. {
  17. OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=SimpleBank.mdb");
  18. connection.Open();
  19. OleDbCommand command = connection.CreateCommand();
  20. command.CommandText = "SELECT AccountID, Owner from Account";
  21. OleDbDataReader reader = command.ExecuteReader();
  22. while(reader.Read())
  23. {
  24. Console.WriteLine("t{0}t{1}",reader["AccountID"],reader["Owner"]);
  25. }
  26. reader.Close();
  27. connection.Close();
  28. Console.ReadLine();
  29. }
  30. }
  31. }