Dela via


How to: Add a SQL Server Database as a Data Source (Devices)

You can use SQL Server databases as data sources in your managed device projects.

To add a SQL Server data connection to Server Explorer

  1. On the View menu, click Server Explorer.

  2. In the Server Explorer window, right-click Data Connections, and then click Add Connection on the shortcut menu.

  3. In the Add Connection dialog box, click Change.

  4. In the Change Data Source dialog box, select Microsoft SQL Server, and then click OK to reopen the Add Connection dialog box.

  5. In the Server name box, specify the name of the server where the data source is located.

  6. Log on to the server.

    If the server uses SQL Server Authentication, you need to provide a user name and password.

  7. In the Select or enter a database name box, select or type the name of the database, and then click OK.

    The new data connection is displayed in Server Explorer.

To use a SQL Server data connection as a data source in a project

  1. Prerequisite: You must have a .NET Compact Framework smart device project already open in the Visual Studio IDE.

  2. On the Data menu, click Add New Data Source to open the Data Source Configuration Wizard.

  3. On the Choose a Data Source Type page, select Database, and then click Next.

  4. On the Choose Your Data Connection page, click New Connection.

  5. In the Add Connection dialog box, click Change.

  6. In the Change Data Source dialog box, select Microsoft SQL Server, and then click OK to reopen the Add Connection dialog box.

  7. In the Server name box, type or select the name of the server where the data source is located.

  8. Log on to the server.

    If the server uses SQL Server Authentication, you need to provide a user name and password.

  9. In the Select or enter a database name box, select or type the name of the database, and then click OK.

  10. In the Choose Your Data Connection page, choose to exclude sensitive data from the connection string, and then click Next.

    Security noteSecurity Note:

    Including sensitive data in the connection string poses a security risk.

  11. On the Choose Your Database Objects page, select the objects you want to use as data sources, and then click Finish.

    The data connection now appears as a data source in the Data Sources window.

See Also

Concepts

Data Access Overview (Managed Device Projects)