dreader2.cs
资源名称:Visual.rar [点击查看]
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:1k
源码类别:
C#编程
开发平台:
Others
- using System;
- using System.Data;
- using System.Data.OleDb;
- namespace DataReader2App
- {
- /// <summary>
- /// Class1 的摘要说明。
- /// </summary>
- class DataReader2
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=SimpleBank.mdb");
- connection.Open();
- OleDbCommand command = connection.CreateCommand();
- command.CommandText = "SELECT AccountID, Owner from Account";
- OleDbDataReader reader = command.ExecuteReader();
- while(reader.Read())
- {
- Console.WriteLine("t{0}t{1}",reader["AccountID"],reader["Owner"]);
- }
- reader.Close();
- connection.Close();
- Console.ReadLine();
- }
- }
- }