日期:2011-05-20 浏览次数:20428 次
ASP.NET[C#]的ACCESS数据库操作类
//网上很多都是操作SQL SER 的,整理了一下,不是很完善,但不影响使用,呵呵……
//private string datapatch = ConfigurationSettings.AppSettings["acessconn"];//数据库地址
private string datapatch = "db/global.asa";//数据库地址
///
/// 取得dataset
///
/// 查询语句
///
public DataSet GetDataSet(string Commandtext)
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath(datapatch);
string strCommandText = Commandtext;
OleDbConnection myConnection = new OleDbConnection(strConnection);
myConnection.Open();
OleDbDataAdapter myAdpater = new OleDbDataAdapter(strCommandText,myConnection);
OleDbCommandBuilder myBuilder = new OleDbCommandBuilder(myAdpater);
DataSet myDataset = new DataSet();
myAdpater.Fill(myDataset);
myConnection.Close();
return myDataset;
}
///
/// 取得表
///
/// 查询语句
///
public DataTable GetDataTable(string Commandtext)
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath(datapatch);
string strCommandText =Commandtext;
OleDbConnection myConnection = new OleDbConnection(strConnection);
myConnection.Open();
OleDbDataAdapter myAdpater = new OleDbDataAdapter(strCommandText,myConnection);
OleDbCommandBuilder myBuilder = new OleDbCommandBuilder(myAdpater);
DataSet myDataset = new DataSet();