日期:2014-05-16 浏览次数:20969 次
namespace ConnectionAccess
{
public partial class Frm_Main : Form
{
private void Frm_Main_Load()
{
string ConStr = string.Format(
@"Provider=Microsoft.ACE.OleDB.12.0;Data Source='D:\1.accdb'",
Application.StartupPath);
OleDbConnection oleCon = new OleDbConnection(ConStr);
oleCon.Open();
OleDbDataAdapter oleDap = new OleDbDataAdapter("select * from 物品列表",oleCon);
DataSet ds = new DataSet();
oleDap.Fill(ds,"T1");
if (ds.Tables!= null)
{
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "T1";
}
oleCon.Close();
oleCon.Dispose();
}
public Frm_Main()
{
Frm_Main_Load();
InitializeComponent();
}
}
}