[align=center]做了一个网站visual2005+access,在本地运行是好的,数据库连接语句是OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=App_Data\tauri_xuxu.mdb;Persist Security Info=False");
发布之后上传到网上,就报错了!连接语句怎么写啊?
项目文件里有这些文件:App_Data  、bin、bindDateTest.sln、PrecompiledApp.config、Web.Config.......数据库文件就在App_Data  里错误如下:
Server Error in '/' Application.
--------------------------------------------------------------------------------'c:\windows\system32\inetsrv\App_Data\tauri_xuxu.mdb'不是一个有效的路径。 确定路径名称拼写是否正确,以及是否连接到文件存放的服务器。 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: 'c:\windows\system32\inetsrv\App_Data\tauri_xuxu.mdb'不是一个有效的路径。 确定路径名称拼写是否正确,以及是否连接到文件存放的服务器。
听说,放到网上去要改数据库连接字符串的怎么改?各位同行帮帮忙!小弟不胜感激![/align]

解决方案 »

  1.   

    Data Source=|DataDirectory|\tauri_xuxu.mdb;
      

  2.   


    Source=App_Data\tauri_xuxu.mdb;将上面这个改成下面这个试试Source=..\App_Data\tauri_xuxu.mdb;
      

  3.   

    1楼的这个可以哦,这下子好了。但是如果我把wwwroot里的App_data里的tauri_xuxu.mdb 放到项目的上一级目录也是databases里面呢,那该怎么写?
    注:wwwroot和databases是同一级别的!
      

  4.   

    |DataDirectory|标记会直接找你的App_Data文件夹,App_Data是受系统保护的,你自己创建的databases文件夹是不受保护的,数据库文件可以被恶意下载,所以不要那么做.