Share via


How to: Create a Database (Devices)

You can create a SQL Server Compact 3.5 database whether you have a project open or not. The database you create can be managed in Visual Studio but is not associated in any way with your device project. To use the database in your device project, you must add the database to your device project as a data source. For more information, see How to: Add a Database to a Device Project.

Important noteImportant Note:

Two or more processes cannot simultaneously access the same SQL Server Compact 3.5 database over a network share because the second process will cause a file-sharing violation error. However, a process can open multiple connections to the database. For example, the process can run an Insert query on one connection and a Select query on another connection at the same time. 

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To create the database outside a project

  1. On the View menu, click Server Explorer.

  2. Right-click Data Connections, and then click Add Connection to open the Add Connection dialog box.

  3. In the Data source box, click Microsoft SQL Server Compact 3.5, and then click Continue.

  4. In the Add Connection dialog box, select My Computer.

  5. Click Create.

  6. In the Create New SQL Server Compact Database dialog box, type a fully qualified path for the new database (for example, c:\MyDB).

  7. In the New Password and Confirm Password boxes, type a password (for example, MyPassword) as the password for the new database, and then click OK.

    Security noteSecurity Note:

    For projects that will be used in real-world applications, select a strong password.

  8. Click OK to return to the Add Connection dialog box.

  9. In the Add Connection dialog box, click Test Connection to ensure that the connection has been made.

    The message that appears indicates that the test connection succeeded.

    Note

    SQL Server Compact 3.5 does not support opening database files on a network share.

  10. Click OK to return to the Add Connection dialog box, and then click OK to close it.

    You have created an empty SQL Server Compact 3.5 database that is visible and manageable in Server Explorer. You can use Server Explorer to manage the database and manipulate data. However, at this point, the database is not associated with your device project. To use the database in your device project, see How to: Add a Database to a Device Project.

See Also

Concepts

Using SQL Server Compact 3.5 Databases (Devices)

Other Resources

Create Database Dialog