/// <summary>
/// 执行查询语句,返回DataSet
/// </summary>
/// <param name="SQLString">查询语句</param>
/// <returns>DataSet</returns>
public static DataSet Query(string SQLString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
connection.Open();
OleDbDataAdapter command = new OleDbDataAdapter(SQLString, connection);
command.Fill(ds, "ds");
}
catch (System.Data.OleDb.OleDbException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}
数据库 链接 字符串:
<add name="OLEDBConn" connectionString="provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|db.mdb " providerName="System.Data.OLEDB"/>
|DataDirectory| 的意思是 APP_DATA 文件夹。
只需要是 把数据库放在该文件夹下即可。