各位大侠,请教:     
    在Web.Config文件里,怎么写access数据库连接字符串?
    如这样的形式:<appSettings>
            <add key="" value=""></add>
                </appSettings>

解决方案 »

  1.   

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"
      

  2.   

    <appSettings>
        <add key="connecting" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"></add>
    </appSettings>
      

  3.   

    你好,lovefootball(蟑螂) :
        能写的详细一点吗?加上
           <appSettings>
           </appSettings>
      

  4.   

    <appSettings>
        <add key="connecting" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"></add>
    </appSettings>你可以参见www.connectionstrings.com
      

  5.   

    "somepath",能用虚拟路径吗?
        上传到远程服务器根目录的DataBase目录下,"Data Source=\somepath\mydb.mdb"这一部分该如何写?
      

  6.   

    to "somepath",能用虚拟路径吗?<appSettings>
    <add key="FileFullPath" value="DataBase/mydb.mdb"></add>
    </appSettings>------In your web app-----
    string strFileFullPath = Server.MapPath( ConfigurationSettings.AppSettings["FileFullPath"] );
    string strConn = string.Format( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};",
       strFileFullPath );
      

  7.   

    <appSettings>
        <add key="connecting" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"></add>
    </appSettings>
      

  8.   

    你好,Knight94(愚翁):
        首先,先谢谢你!你讲得更详细。
        我想请教一个问题:
            我发现了一个问题,使用这种方法时,处在不同层的页面代码不能使用同一个连接字符串,例如:
                 (虚拟目录)目录: /file1/file2/file3
                 (虚拟目录)数据库目录:/file1/mydb.mdb
                 (虚拟目录)页面目录:页面1目录:/file1/WebForm1
                                页面2目录:/file1/file2/WebForm2
        ---web app----
            <appSettings>
                <add key="FileFullPath1" value="mydb.mdb"></add>
                <add key="FileFullPath2" value="../mydb.mdb"></add>
            </appSettings>
       页面1的连接字符串:
                          string strFileFullPath = Server.MapPath( ConfigurationSettings.AppSettings["ConnectionString1"] );
          string strConn = string.Format( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};",strFileFullPath );
       页面2的连接字符串:
                          string strFileFullPath = Server.MapPath( ConfigurationSettings.AppSettings["ConnectionString2"] );
          string strConn = string.Format( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};",strFileFullPath );   我想请教:
               页面1和页面2能不能使用同一个连接字符串?
               是我的用法有问题?还是只能这样用?还是还有别的方法?
      

  9.   

    to 页面1和页面2能不能使用同一个连接字符串?你可以在webapp中的Global文件去做,然后存在session中,那么页面访问的时候,直接从session去取即可。
      

  10.   

    to  你可以在webapp中的Global文件去做,然后存在session中,那么页面访问的时候,直接从session去取即可
        在Global文件中怎么做?怎么存到session中,你能详细的说一下吗?谢谢
      

  11.   

    <appSettings>
        <add key="connecting" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=mydb.mdb;Jet OLEDB:Database Password=sa;"></add>
    </appSettings>
      

  12.   

    to 在Global文件中怎么做?怎么存到session中,你能详细的说一下吗?
    protected void Session_Start(Object sender, EventArgs e)
    {
    //Get app setting
    try 
    {
                 string strFileFullPath = Server.MapPath(              ConfigurationSettings.AppSettings["FileFullPath"] );
                 string strConn = string.Format( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};",
    strFileFullPath );
                 Application["ConnectionString"] = strConn;
    }
    catch(Exception err)
    {
    Application["ErrorString"]=err.Message;
    }
    }
      

  13.   

    谢谢各位大侠的帮助!特别感谢Knight94(愚翁)!