dreader3.cs
资源名称:Visual.rar [点击查看]
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:1k
源码类别:
C#编程
开发平台:
Others
- using System;
- using System.Data;
- using System.Data.OleDb;
- namespace DataUpdateApp
- {
- /// <summary>
- /// Class1 的摘要说明。
- /// </summary>
- class DataUpdate
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=SimpleBank.mdb");
- connection.Open();
- OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Account",connection);
- OleDbCommandBuilder builder2 = new OleDbCommandBuilder(adapter);
- DataSet dataset = new DataSet();
- adapter.Fill(dataset,"Account");
- Console.WriteLine("name before change:{0}",dataset.Tables["Account"].Rows[5]["Owner"]);
- dataset.Tables["Account"].Rows[5]["Owner"] = "Andrew5";
- adapter.Update(dataset,"Account");
- Console.WriteLine("name after change:{0}",dataset.Tables["Account"].Rows[5]["Owner"]);
- connection.Close();
- Console.ReadLine();
- }
- }
- }