Use SQL Server express for ASP. NET (Visual Studio)

Source: Internet
Author: User
Tags microsoft sql server 2005 sql server express

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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.