ArticleDirectory
Connect to the SQL Server express Database
Microsoft SQL Server 2005 express edition generates applicationsProgramProvides a simple database solution. SQL Server express supports the complete SQL Server 2005 programming model, including Transact-SQL, stored procedures, views, triggers, SQL Server CLR integration (sqlclr), and XML data types. When you develop an application that uses SQL Server express as the data source, you can ensure that the application is compatible with the production server running SQL Server 2005.
Connect to the SQL Server express Database
By specifying the database server as a local SQL Server express data source, you can connect to the SQL Server express database, just as you connect to any SQL Server database. For example, the following connection string is connected toMERs.
Data Source =. \ sqlexpress; initial catalog = MERs MERS; Integrated Security = true;
You can specify a database file to be appended by using the attachdbfilename parameter that replaces the initialcatalog or database connection string attribute. You can use the file name to connect to the database to simplify the deployment of the database and applications (if the target server runs SQL Server express ). For example, the following connection string is stored inCustomers. MDFFile.
Data Source =. \ sqlexpress; attachdbfilename = E: \ data \ customers. MDF; Integrated Security = true; user instance = true
ASP. NET provides convenient options for storing data in the app_data directory of Web applications. The content in the app_data directory is not provided in response to Web requests, which improves the data security of applications. You can also provide| Datadirectory |Concatenate string variables to replace the file path in the app_data directory of the application. ASP. net function (such as the sqldatasource control or the provider used for membership, role, user configuration file, Web Part personalized settings, etc.) automatically replaces the file path of the app_data directory| Datadirectory |Concatenate string variables. If you move the web application to another directory, this ensures that the database path is up to date. The followingCodeThe example shows| Datadirectory |The connection string that connects the string variable.
Data Source =. \ sqlexpress;Attachdbfilename = | datadirectory | MERs. MDF;Integrated Security = true; user instance = true
Original: http://msdn.microsoft.com/zh-cn/partners/ms247257 (vs.80). aspx