.net连接ACCESS数据库找不到路径的问题
用的是VS2005
web.config文件:
<appSettings>
<add key= "ConnStr " value= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=/App_Data/qwins.mdb "/>
</appSettings>
连接数据库的类文件DConn.cs:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
/// <summary>
/// conn 的摘要说明
/// </summary>
namespace AccConn
{
public class DConn
{
protected string Conn=ConfigurationSettings.AppSettings[ "ConnStr "];//连接数据库
protected string AccSql;
OleDbConnection ConnString;
public DConn(string AccSql)
{
//
// TODO: 在此处添加构造函数逻辑
//
ConnString=new OleDbConnection(Conn);//创建一个实例
this.AccSql=AccSql;
}
public DataSet DsSql()
{
OleDbDataAdapter da = new OleDbDataAdapter(AccSql, ConnString);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
}
}
显示页面的类文件default.aspx.cs:
using System;
using System.Data;
using System.Configuration;
//using System.ComponentModel;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using AccConn;//命名空间
using System.Collections;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DConn Dc = new DConn( "Select * from news order by id asc ");
DataSet ds = Dc.DsSql();
&nbs