嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
读取Access 数据库数据
private void button1_Click(object sender, EventArgs e)
{
string ConStr = string.Format(//设置数据库连接字符串
@"Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:DataBase Password='{0}';
User Id=admin;Data source=D:\软件安装\Microsoft access 2003\工时与帐单1.mdb",
textBox1.Text, Application.StartupPath);
// string ConStr = string.Format(//设置数据库连接字符串
// @"Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:DataBase Password='{0}';
//User Id=admin;Data source={1}\工时与帐单1.mdb",
// textBox1.Text, Application.StartupPath);
OleDbConnection oleCon = new OleDbConnection(ConStr);//创建数据库连接对象
OleDbDataAdapter oleDap = new OleDbDataAdapter(//创建数据适配器对象
"SELECT * FROM ZZZ", oleCon);
DataSet ds = new DataSet();//创建数据集
oleDap.Fill(ds, "ZZZ");//填充数据集
this.dataGridView1.DataSource =//设置数据源
ds.Tables[0].DefaultView;
oleCon.Close();//关闭数据库连接
oleCon.Dispose();//释放连接资源
}
}
}