datadirectory

How to use |DataDirectory| substitution string in appsettings.json with asp.net core?

孤者浪人 提交于 2021-01-28 12:40:24
问题 I'm new to asp.net core and the task I want to do should be very simple. Using Visual Studio, I'm trying to link a .mdf file to my project as a local database. As I want to make it work for several computers, I need to find the data directory folder path from appsettings.json. Therefore, after some researches, the best way to do that is using the |DataDirectory| substitution string. The problem is that my website can't reach my mdf file this way and it generates an ArgumentException :

Install arbitrary data files in fixed location with Automake?

时光总嘲笑我的痴心妄想 提交于 2019-12-19 07:24:37
问题 How can I tell automake to install arbitrary data files in places I want? I have some files I need to put in specific places, e.g. " datafile1 ", in my project, needs to be copied to " /usr/MyProduct/flash_memory ". " /usr/MyProduct/flash_memory " is an absolute path that I can't change. " datafile1 " is a binary data file that is not "built" by make , but just needs to be copied by make install . I can't bear on make dist . It needs to be copied by make install (its a long explanation, so,

Connection String to Connect to .MDF

我的未来我决定 提交于 2019-12-17 19:18:09
问题 I've created a new project in VS2008, and added a .MDF file to the project. This is the first time I've tried to use the MDF files and .SQLEXPRESS databases (I've always used extenal Oracle servers in the past). I'm trying to document everything as I go, but I can't figure out what credentials are being used to connect to the .MDF file. Is there an easy way to find out? 回答1: If you're using the *.mdf file in the App_Data folder of an ASP.NET app you can use this. Server=.\SQLExpress

How do I read the current path of |DataDirectory| from config settings

孤街浪徒 提交于 2019-12-17 13:22:34
问题 I'm writing a program that requires the user to select the active database at application startup. I have a Windows Form that will list the databases stored in a sub-folder of ApplicationData specifically for storing the database files. When I create a new database, however, I need to copy the the template database, but can't figure out where it's stored by default. I've tried: dpath = ConfigurationManager.AppSettings["DataDirectory"]; I always seem to get a null value in return though. At

ADO.NET |DataDirectory| where is this documented?

人走茶凉 提交于 2019-12-16 20:07:25
问题 In AppConfig it is possible to use |DataDirectory| but I can't find any doc ? 回答1: |DataDirectory| is a substitution string so you can configure the location of your database file separately. So instead of: SqlConnection c = new SqlConnection ( @"Data Source=.\SQLDB; AttachDbFilename=C:\MyDB\Database.mdf;Initial Catalog=Master"); you do the following: // Set |DataDirectory| value AppDomain.CurrentDomain.SetData("DataDirectory", "C:\myDB"); // SQL Connection String with |DataDirectory|

SQL Server Compact 'Data Directory' macro in Connection String - more info needed

巧了我就是萌 提交于 2019-12-08 17:34:16
问题 So, as described on this msdn page, when you define a Connection String for SQL Server Compact 3.5, you can use the "Data Directory" macro, like this: quote from this msdn page: Data Directory Support SQL Server Compact 3.5 now supports the Data Directory macro. This means that if you add the string |DataDirectory| (enclosed in pipe symbols) to a file path, it will resolve to the path of the database. For example, consider the connection string: "Data Source= c:\program files\MyApp\Mydb.sdf"

|DataDirectory|解决webconfig数据库连接的相对路径问题

别说谁变了你拦得住时间么 提交于 2019-12-05 17:50:33
webconfig中的数据库连接是不支持Server.MapPath的,一般我们只能写上数据库文件的物理路径,这给网站迁移带来很大的不方便。今天在网上找到了一个解决办法,与大家分享下。看以下代码: <connectionStrings> <add name="ConnStr_Access" providerName="System.Data.OleDb" connectionString= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\cms.mdb;" /> </connectionStrings> |DataDirectory|会被自动解析到App_Data 下面是MSDN的说明: 使用 DataDirectory 替代字符串 AttachDbFileName 已在 ADO.NET 2.0 中进行了扩展,引入了 |DataDirectory| (包含在管道符号中)替代字符串。 DataDirectory 与 AttachDbFileName 结合使用可指示数据文件的相对路径,允许开发人员创建基于数据库源的相对路径(而无需指定完整路径)的连接字符串。 DataDirectory 点的物理位置取决于应用程序的类型。 在此示例中,要附加的 Northwind.mdf 文件位于应用程序的 \app_data

Install arbitrary data files in fixed location with Automake?

做~自己de王妃 提交于 2019-12-01 05:11:49
How can I tell automake to install arbitrary data files in places I want? I have some files I need to put in specific places, e.g. " datafile1 ", in my project, needs to be copied to " /usr/MyProduct/flash_memory ". " /usr/MyProduct/flash_memory " is an absolute path that I can't change. " datafile1 " is a binary data file that is not "built" by make , but just needs to be copied by make install . I can't bear on make dist . It needs to be copied by make install (its a long explanation, so, pelase just take this into account). I rather not use install-hook , but prefer to have a more elegant

How to define DataDirectory for ConnectionString in console application to work with EntityFramework Code First Migrations

末鹿安然 提交于 2019-11-29 03:05:24
问题 I try to set location MyProject\App_Data\Cos.mdf for the database in App.config : <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\Cos.mdf;Initial Catalog=Cos;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /> </connectionStrings> In Program.cs I wrote: static void Main(string[] args) { string relative = @"..\..\App_Data\Cos.mdf"; string absolute = Path.GetFullPath