You must connect to a database before you can view, add, or drop database objects on the Objects tab; or before you can execute queries against a database on the SQL tab. Use the Objects tab to manage database connections. If you are connecting to a database for the first time, it is added to the list of managed databases in the Databases folder. If you are connecting to a database that was connected to previously, the database is already listed under the Databases folder.

To connect to a database for the first time

  1. On the Objects tab, select the Databases folder.

  2. Tap the database connection button. The button must show a green arrow. If the button shows a red square, you are already connected to a database. Tap the button to disconnect. Microsoft SQL Server Compact 3.5 permits only one database connection at a time.

  3. In the Connect to SQL Server Compact 3.5 dialog box, enter the path for the database or tap the browse () button to select a database.

    On a Handheld PC device, you can find the root directory to locate a database. On a Pocket PC device, you can locate the My Documents folder. To locate databases at the root directory, which includes any sample databases, type a backslash (\) in front of the database name. For example, to connect to Northwind.sdf, type \Northwind.sdf.

  4. If the database is password protected, enter a password.

  5. Tap Connect.

Icon to connect to a database

Indicates no current connection to the database. Tap to connect.

Icon to disconnect a database

Indicates an established connection to the database. Tap to disconnect.

ms173010.UpgradeIcon(en-us,SQL.105).gif

Tap to upgrade the database to SQL Server Compact 3.5.

To connect to a database that was connected to previously

  • On the Objects tab, expand the Databases folder, select the database, and then tap the database connection button.

    If a database connection is underway when you try to connect to another database, SQL Server Compact 3.5 drops the current connection and starts a new connection as part of the same operation. If you exit SQL Server Compact 3.5 Query Analyzer without closing a database connection, when you restart SQL Server Compact 3.5 Query Analyzer, the Objects tab shows the last database connection and the last view.

To disconnect from the current database

  • On the Objects tab, select either the Databases folder or the database you want to disconnect from, and then tap the database connection button. Before you tap, the button displays a red square. If the button displays a green arrow, you are already disconnected.

To remove a single database from the list of managed databases in the Databases folder

  1. Select the database you want to remove. If you are connected to the database, you must disconnect.

  2. Tap the database management button. In the message window that appears, tap OK.

Icon to stop managing the database

Tap to stop managing the database.

To remove all databases from the list of managed databases in the Databases folder

  1. Disconnect from the current database, if it is required.

  2. Select the Databases folder, and then tap the database management button.

To compact and repair a database

  1. Disconnect from the current database, if it is required.

  2. Select the database you want to compact and repair, and then tap the compact and repair button.

Icon to compact and repair a database

Tap to compact and repair the database.

For information about compacting and repairing a database, see Using and Maintaining Databases (SQL Server Compact).