Asp.net 2.0 has a special directory app_data. Generally, the SQL Server 2005 express data file is stored in this directory. The corresponding database connection string is:
Connectionstring = "...... Data Source =. \ sqlexpress; Integrated Security = sspi; attachdbfilename = | datadirectory | data. MDF; user instance = true"
Here is a macro of datadirectory. What does it mean?
Datadirectory indicates the replacement string of the database path. Datadirectory simplifies project sharing and application deployment because it does not require hard coding of the complete path. For example, you do not need to use the following connection string:
"Data Source = c: \ Program Files \ MyApp \ app_data \ mydb. MDF"
Use | datadirectory | (included in the following vertical line) to have the following connection string:
"Data Source = | datadirectory | \ mydb. MDF"
Datadirectory is not only used in SQL Server 2005 Express, but can also be used in other file databases, such as the connection string of the sqllite database file:
<Add name = "defaultdb"
Connectionstring = "driverclass = nhib.pdf. Driver. sqlite20driver; dialect = nhib.pdf. dialect. sqlitedialect; Data Source = | datadirectory | \ data. db3"/>
This article is from the csdn blog,
Source: http://blog.csdn.net/leon_ice/archive/2009/08/08/4426281.aspx