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"
When using Data Directory, you can instead use the following connection string:
"Data Source = |DataDirectory|\Mydb.sdf"
For more information, see How to: Deploy a SQL Server Compact 3.5 Database with an Application.
However, the 'for more information' link on msdn doesn't actually give any more information.
So my question is:
How does the |Data Directory| macro translate at run time? For WinForm apps, it seems to just give the location of the executable. Or is it more complicated than that?
To set the DataDirectory property, call the AppDomain.SetData method. If you do not set the DataDirectory property, the following default rules will be applied to access the database folder:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With