The use of VS2015 LOCALDB database __ Database

Source: Internet
Author: User

For programmers, the process of programming is more or less dealing with databases. If you are using Visual Studio for program development, Microsoft's SQL Server database is the best choice. The problem, however, is that SQL Server databases take several g, and the amount of space that is used after installation is considerable, and is not a requirement for each developer to install SQL Server when developing. In fact, for small projects, test-type projects, learning-type project development, there is no need to use SQL Server so large database. Microsoft itself knows this, so it has launched a super simplified version of the SQL Server database: SQL Server LocalDB. This small database can fully meet the development and commissioning of common projects, the key is that it only dozens of m, can greatly reduce the operating pressure of the PC. This article will briefly describe how to use the LocalDB database in Visual Studio 2015.

First, the installation of LocalDB

LocalDB is automatically installed when VS2015 is installed, so localdb is certain if the VS2015 is installed properly.

Ii. connection and management of LOCALDB

Entering VS2015, select Sql Server Object Explorer in view, and you can see the following interface.

Right-click SQL Server to select Add SQL Server.

Browsing Local in the pop-up form, you can see two database instances: Mssqllocaldb and ProjectsV13. These two examples are VS2015 localdb, there are two, because the landlord's VS2015 has been updated, Mssqllocaldb is a V12 version of the LOCALDB,PROJECTSV13 is a V13 version of the LocalDB, Both can now be used by VS2015 projects. Next, take mssqllocaldb as an example to connect. After a successful connection, the resource manager on the left can manage the resources of the database.

Then we can try to create a new database test.

After you successfully create the test database, you can operate the database normally. However, if you are connecting to an external database file, you cannot operate directly in SQL Server Explorer, and you need to operate in Server Explorer. The process is as follows:

Select Add Connection in Server Explorer and if you connect directly to the external database file, the file is appended to LocalDB by default:

In the pop-up form, select Browse to add the external database file:

After selecting the file, click OK, and the Server Explorer has one more connection to the external database file:

Looking at the MSSQLLOCALDB in SQL Server Object Explorer again, you can see that the external database that you just added is attached to this local database:

At this point, the external database is also attached, and if you want to connect the database to the project, the connection string is as follows:

"Data source= (LocalDB) \\MSSQLLocalDB; Attachdbfilename= the absolute path of the external database file (note the escape character).

Turn from: http://www.cnblogs.com/Traveller-Lee/archive/2016/08/16/5776312.html

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.