我希望有高人能帮我解决这个小问题...最好能给我一个小案例看看....

解决方案 »

  1.   

    <appSettings> 
    <add key="SQLConnString" value="provider=microsoft.jet.oledb.4.0;data source="/> 
    <add key="dbPath" value="~/App_Data/mydata.mdb"/> 
    </appSettings>
      

  2.   

    public static readonly string strConn = System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString() + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["dbPath"]) + ";"; 
      

  3.   

    //using System.Data.OleDb; 
    protected void Button1_Click(object sender, EventArgs e) 
        { 
    OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|\\studentinfo.mdb"); 
                conn.Open(); 
    string sqlstr = "select * from basic_info"; 
    OleDbDataAdapter da = new OleDbDataAdapter(sqlstr, conn); 
                        OleDbCommandBuilder cmd = new OleDbCommandBuilder(da); 
                        DataSet ds = new DataSet(); 
                        da.Fill(ds, "basic_info"); 
                        conn.Close(); 
        } 
      

  4.   

    呵呵顶楼上的,cs代码里把SQLConnString + dbPath 就好了
      

  5.   

     1.string strcon = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("App_Data/001.mdb");
            OleDbConnection con = new OleDbConnection(strcon);
    con.Open();
    或者 在web.config中定义链接字符串。
      

  6.   

    配置文件中写:<appSettings> 
    <add key="SQLConnString" value="provider=microsoft.jet.oledb.4.0;data source="/> 
    <add key="dbPath" value="~/App_Data/mydata.mdb"/> 
    </appSettings>CS类文件中写:public static readonly string strConn = System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString() + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["dbPath"]) + ";"; //OleDbConnection需要引用命名空间类似:using System.*****OleDbClient;OleDbConnection conn = new OleDbConnection(strConn);conn.Open(); //使用类似:string sqlstr = "select * from basic_info"; 
    OleDbDataAdapter da = new OleDbDataAdapter(sqlstr, conn); 
                        OleDbCommandBuilder cmd = new OleDbCommandBuilder(da); 
                        DataSet ds = new DataSet(); 
                        da.Fill(ds, "basic_info"); 
                        conn.Close(); 
      

  7.   

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;
      

  8.   

    <appSettings>
        <add key="DAL" value="JinHui"/>
        <add key="ConnectionString"  value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|DB\JHPSS.mdb"/>
      </appSettings>将数据库放到项目表示层的bin\Debug目录下,这样项目就可以随处移动,不用修改数据库连接字符串了。