可以写成相对路径么,在web.config文件中,

解决方案 »

  1.   

    在application_start用application("strconnection")=="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+httpcontext.current.server.mappath(\data\cxam.mdb"+";Jet OLEDB:Database Password=abc"
    然后可以用
    dim cnn as new oledbconnection(application("strconnection"))
      

  2.   

    IIS6.0想使用
    ../xx/xx.mdb
    这样的路径需要自定义设置在应用程序配置里面启用父路径就可以了
      

  3.   

    可以在config文件里写相对路径
    <appSettings>
      <add key="DataSource" value="data\user.mdb" />
    <add key="Provider" value="Provider = Microsoft.Jet.OLEDB.4.0;" />
      </appSettings>
      

  4.   

    强烈建议,数据不放在可以通过http可以访问的到的路径下面。
    通过更改aspnet用户的权限,将可以达到目的。
    如:c:/inetpub/wwwroot/为web服务根目录,
    则你可以将data.mdb放在:c:/inetpub/下,然后通过web.config指向它。
    这样保证你数据库不可能被http下载。
      

  5.   

    http://www.cnblogs.com/hover/archive/2004/07/22/26666.aspx小技巧:用物理路径读取access数据库 
    Posted on 2004-07-22 21:49 Hover 阅读(79) 评论(0)  编辑 收藏 
    private static string Constring;
            /**//// <summary>
            /// 数据连接字符串
            /// </summary>
            public static string ConnectString
            {
                get
                {
                    if(Constring==null)
                    {
                        Constring=string.Format(System.Configuration.ConfigurationSettings.AppSettings["ConnectString"],
                            System.Web.HttpContext.Current.Request.PhysicalApplicationPath+(System.Configuration.ConfigurationSettings.AppSettings["DbPath"]));
                        return Constring;                }
                    else
                    {
                        return Constring;
                    }
                }
            }参见Globals.cs <appSettings>
        <add key="ConnectString" value="Data Source={0};Password=;Provider=Microsoft.Jet.OLEDB.4.0" /> <!--数据驱动-->
            <add key="DbPath" value="DataBaseHover.mdb" /><!--物理路径-->
        </appSettings>参见web.config在调用ConnectString时始终是物理路径
    D:\Hover\Hover.Web\DataBase\Hover.mdbHttpRequest.PhysicalApplicationPath 属性
    获取当前正在执行的服务器应用程序的根目录的物理文件系统路径