这是个连接access的例子
using System.Data;
using System.Data.OleDb;
OleDbConnection conn=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据库名字;Jet OLEDB:Database Password=数据库密码"); try
{
conn.Open();
System.Data.OleDb.OleDbCommand oledbcommand=new OleDbCommand("select *  from person",conn);
da=new OleDbDataAdapter(oledbcommand.CommandText,conn);
ds=new DataSet();
da.Fill(ds,"person");
this.dataGridperson.DataSource=ds.Tables[0]; //this.currentmanager=(CurrencyManager)this.BindingContext[ds,"person"];
System.Data.DataView dvperson=new DataView(ds.Tables[0]);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"错误");
}
finally
{
conn.Close();
}