日期:2014-05-19  浏览次数:20357 次

三层构架中的Access数据怎么连接?
请问:在开发三层结构的WEB中,,连接Access数据库,怎么样才能使用server.mapPaht()?不要绝对路径?

------解决方案--------------------
Dim DataPath As String = System.Configuration.ConfigurationManager.AppSettings( "dbpath ")
Dim StrCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & HttpContext.Current.Server.MapPath(DataPath)


web.config:
<appSettings>
<add key= "dbpath " value= "~/mydata/illlli.mdb "/>
</appSettings>

------解决方案--------------------
HttpContext.Current.Request.PhysicalApplicationPath
------解决方案--------------------
private string m_dbConnection;
protected string strSql;
public MDatabase()
{
m_dbConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + HttpContext.Current.Request.PhysicalApplicationPath +
ConfigurationManager.ConnectionStrings[ "PATH "].ConnectionString;

if (m_dbConnection == null)
{
throw new Exception( "Error--> DSN not set in Config.web ");
}
}