问一下:
我现在开发两个系统要同时用到一个access数据库,其中一个系统是web,一个是winform的,我web的开发文件放在c:\\
winform的开发文件放在g:\\下,而accesss则放在g:\\ms\\data文件下,那我web程序怎么样才能连接到access文件呢?不用绝对路径

解决方案 »

  1.   

    IO.Directory.GetCurrentDirctory 获取当前路径
      

  2.   

    Application.StartupPath//应用程序的目录System.IO.Directory.GetCurrentDirectory//当前的工作目录
      

  3.   

    用绝对路径怎么了?我一直在用access的时候用绝对路径.
      

  4.   

    那我的web程序很难定位到access数据库啊,
      

  5.   

    我做的一个(B/S)系统,用access的数据库。下面的是楼主需要的把。public string GetConnectionString ()  
    {
    return "provider=microsoft.jet.oledb.4.0;data source ="+HttpContext.Current.Server.MapPath("/studentmis") +@"\database\sysdb.mdb";
     
    }
    //HttpContext.Current.Server.MapPath("/studentMIS")是获取 在iis中,虚拟目录名字叫studentMIS的  物理磁盘目录  也就是说,把studentMIS改成你的虚拟目录名字就可以了