Connection string with relative path to the database file

后端 未结 10 712
暗喜
暗喜 2020-11-28 07:20

I load data from sdf database in winforms App. I use full path to the database file . Example :

conn = new SqlCeConnection

{

ConnectionString =\"Data Sou         


        
10条回答
  •  醉梦人生
    2020-11-28 08:02

    This worked for me:

    string Connection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
        + HttpContext.Current.Server.MapPath("\\myPath\\myFile.db")
        + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\"";
    

    I'm querying an XLSX file so don't worry about any of the other stuff in the connection string but the Data Source.

    So my answer is:

    HttpContext.Current.Server.MapPath("\\myPath\\myFile.db")
    

提交回复
热议问题