如何连接MDB数据,并且获取相关的数据

不说了直接上代码:

try{

String str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + address + "'";
con = new OleDbConnection(str);
con.Open();
OleDbCommand cmd = con.CreateCommand();

//获得数据

OleDbDataAdapter dagroup = new OleDbDataAdapter("select DATA_NAME from BL_BUILD group by DATA_NAME ", con);
DataSet dsgroup = new DataSet();
dagroup.Fill(dsgroup, "ddgroup");

//执行sql  语句

cmd.CommandText = item;
 int num = cmd.ExecuteNonQuery();

 con.Close();

}

catch (Exception ex)
{
con.Close();
con.Dispose();
throw ex;
}

  喜欢给我留言哦

posted @ 2017-03-31 15:26  需要GIS小工具找我  阅读(574)  评论(0编辑  收藏  举报