在 PowerApps 中添加数据连接Add a data connection in PowerApps

在 PowerApps 中,向现有应用或从头开始生成的应用添加数据连接。In PowerApps, add a data connection to an existing app or to an app that you're building from scratch. 本主题使用的是 PowerApps Studio,也可以使用 powerapps.com,如管理连接主题所述。In this topic, you use PowerApps Studio, but you can also use powerapps.com, as the Manage connections topic describes.

应用中添加的数据连接可以连接 SharePoint、Salesforce、OneDrive 或许多其他数据源之一Your app's data connection can connect to SharePoint, Salesforce, OneDrive, or one of many other data sources.

阅读完本文的后续步骤是,在应用中显示和管理相应数据源中的数据,如下面这些示例所述:Your next step after this article is to display and manage data from that data source in your app, as in these examples:

  • 连接到 OneDrive,并在应用中管理 Excel 工作簿中的数据。Connect to OneDrive, and manage data in an Excel workbook in your app.
  • 连接到 Twilio,并从应用发送短信。Connect to Twilio, and send an SMS message from your app.
  • 连接 SQL Server,然后通过应用更新表。Connect to SQL Server, and update a table from your app.

先决条件Prerequisites

注册安装 PowerApps,然后打开该程序,并提供注册所用的同一凭据进行登录。Sign up for PowerApps, install it, open it, and then sign in by providing the same credentials that you used to sign up.

数据连接的背景知识Background on data connections

大多数 PowerApps 应用使用称为“数据源”的外部信息,此类信息存储在云服务中。Most PowerApps apps use external information called Data Sources that is stored in cloud services. 常见的例子是,OneDrive for Business 中存储的 Excel 文件中的表。A common example is a table in an Excel file stored in OneDrive for Business. 应用可以使用连接器访问这些数据源。Apps are able to access these data sources by using Connectors.

最常见的数据源是可用于检索和存储信息的表。The most common data sources are tables, which you can use to retrieve and store information. 可以使用数据源连接器,在 Microsoft Excel 工作簿、SharePoint 列表、SQL 表和其他许多格式数据源中读取和写入数据,这些数据源可以存储在 OneDrive for Business、DropBox、SQL Server 等云服务中。You can use connectors to data sources to read and write data in Microsoft Excel workbooks, SharePoint lists, SQL tables, and many other formats, which can be stored in cloud services such as OneDrive for Business, DropBox, SQL Server, etc.

除表以外的其他数据源包括电子邮件、日历、Twitter 和通知。Data sources other than tables include email, calendars, Twitter, and notifications.

使用“”、“显示窗体”和“编辑窗体”控件,可以轻松创建在数据源中读取和写入数据的应用。Using the Gallery, Display form, and Edit form controls, it's easy to create an app that reads and writes data from a data source. 若要开始,请阅读了解数据窗体一文。To get started, read the article Understand data forms.

添加连接Add a connection

  1. 单击或点击“文件”菜单(左边缘附近)上的“新建”。Click or tap New on the File menu (near the left edge).

    “文件”菜单上的“新建”选项

  2. 在“空白应用”磁贴上,单击或点击“手机布局”。On the Blank app tile, click or tap Phone layout .

    从头开始创建应用

  3. 在中心窗格中,单击或点击“连接到数据”。In the center pane, click or tap connect to data.
  4. 如果“数据”窗格中的连接列表包含要使用的连接,请单击或点击相应连接,将其添加到应用中。If the list of connections in the Data pane includes the one that you want, click or tap it to add it to the app. 否则,请跳到下一步。Otherwise, skip to the next step.

    添加数据源

  5. 单击或点击“新建连接”,查看连接器列表。Click or tap New connection to display a list of connectors.

    添加连接

  6. 滚动浏览连接器列表,直到发现要创建的连接类型(例如,Office 365 Outlook),然后单击或点击此类型。Scroll through the list of connectors until the type of connection that you want to create appears (for example, Office 365 Outlook), and then click or tap it.

    选择连接

  7. 单击或点击“创建”,创建连接并将其添加到应用中。Click or tap Create to both create the connection and add it to your app.

    某些连接器(如 Microsoft Translator)不需要执行额外步骤即可立即从中显示数据。Some connectors, such as Microsoft Translator, require no additional steps, and you can show data from them immediately. 其他连接器将提示你提供凭据,指定一组特定的数据或执行其他步骤。Other connectors prompt you to provide credentials, specify a particular set of data, or perform other steps. 例如,SharePointSQL Server 需要在使用之前提供其他信息。For example, SharePoint and SQL Server require additional information before you can use them.

查看或更改数据源View or change a data source

如果正在更新应用,则可能需要确定或更改具有 Item 属性的库、窗体或其他控件中显示的数据源。If you're updating an app, you might need to identify or change the source of data that appears in a gallery, a form, or another control that has an Item property. 例如,你可能正在使用其他人创建的应用,或者你可能想要提醒自己你在不久前配置的数据源。For example, you might be working on an app that someone else created, or you might want to remind yourself of a data source that you configured a while ago.

  1. 选择想要为其标识数据源的控件。Select the control for which you want to identify the data source.

    例如,通过在左边缘附近的屏幕和控件的层次结构列表中单击或点击一个库(而非库中的控件)来选择此库。For example, select a gallery (not a control within the gallery) by clicking or tapping it in the hierarchical list of screens and controls near the left edge.

    数据源的名称在右侧窗格的“属性”选项卡上显示。The name of the data source appears on the Properties tab of the right-hand pane.

    “属性”选项卡上的数据源

  2. 若要显示此数据源的详细信息或更改它,请单击或点击右侧窗格中的“数据”。To show more information about the data source or change it, click or tap Data in the right-hand pane.

    “数据”窗格

  3. 若要更改该数据源,请单击或点击该数据源旁的向下箭头,然后选择或创建其他源。To change the data source, click or tap the down arrow next to the data source, and then choose or create another source.

后续步骤Next steps