![]() |
#2
qq10235692232016-02-26 16:19
|
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace 表格处理
{
public partial class Form1 : Form
{
OleDbConnection conn = new OleDbConnection();
OleDbCommand comm = new OleDbCommand();
OleDbDataAdapter adapter = new OleDbDataAdapter();
DataSet ds = new DataSet();
public Form1()
{
InitializeComponent();
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=studentinfo.mdb";
comm.Connection = conn;
= "select * from studentinfo where 分数>75";
adapter.SelectCommand = comm;
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);//处理的新表放在了adapter中
}
private void button1_Click(object sender, EventArgs e)
{
ds.Clear();
adapter.Fill(ds, "good");//现在将adapter中的表以good名称填到ds中
d1.DataSource = ds.Tables["good"];//d1中即将呈现的是新表good
}
private void button2_Click(object sender, EventArgs e)
{
adapter.Update(ds, "good");//更新数据库中的表
}
}
}
只有本站会员才能查看附件,请 登录