How To: Connect to a SQL Server Compact Database by Using Visual Studio

This topic describes how to connect to a SQL Server Compact database by using Visual Studio. 

To connect to a database

  1. Open Visual Studio or Visual Web Developer Express. 

  2. Do one of the following:

    • In Visual Studio, on the View menu, click Server Explorer.

    • In Visual Web Developer Express, on the View menu, click Database Explorer.

  3. Right-click Data Connections, and then click Add Connection.

  4. In the Change Data Source dialog box, select Microsoft SQL Server Compact 4.0, and then click Continue.

  5. In the Add Connection dialog box, browse to the SQL Server Compact 4.0 database.

    Important

    In the Add Connection dialog box, to set the maximum size for a database, click Advanced.

    In the Advanced Properties box, under Max Database Size, specify a database size greater than or equal to the size of the SQL Server Compact database that you plan to connect to. The default value of the Max Database Size property is 256 MB for desktops.