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

Posted by codeulike on Stack Overflow See other posts from Stack Overflow or by codeulike
Published on 2009-10-23T11:54:49Z Indexed on 2010/05/16 0:50 UTC
Read the original article Hit count: 394

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?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about sql-server-ce