当前位置: 代码迷 >> ASP.NET >> 三层构架中的Access数据如何连接
  详细解决方案

三层构架中的Access数据如何连接

热度:9291   发布时间:2013-02-26 00:00:00.0
三层构架中的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 ");
}
}
  相关解决方案