简体   繁体   English

如何具有Microsoft Access驱动程序(.mdb)文件的相对路径

[英]How to have relative path for Microsoft Access Driver(.mdb) file

<connectionStrings>
    <add name="localconnection" connectionString="Driver={Microsoft Access Driver (*.mdb)}; DBQ=D:/abc/pqr/xyz/abc.mdb; UID=;PWD=12345;" providerName="System.Data.SqlClient"/>
</connectionStrings>  

Question: How can i pass relative path for (.mdb) file in web.config file? 问题:如何在web.config文件中传递(.mdb)文件的相对路径? I tried using (../) and (~/) but its not working. 我尝试使用(../)和(〜/),但无法正常工作。 Can any one please help me out. 谁能帮帮我。

In web.config 在web.config中

<connectionStrings>    
   <add name="localconnection" connectionString="Driver={Microsoft Access Driver (*.mdb)} ;pwd=12345; DBQ="/>
</connectionStrings>

In .aspx file 在.aspx文件中

string Connection = ConfigurationManager.ConnectionStrings["localconnection"].ConnectionString + Server.MapPath("//abc//pqr//xyz//abc.mdb");
OdbcConnection SGemsConn = new OdbcConnection(Connection);  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM