使用canvas应用程序表单-本地sql时不断收到错误“使用补丁功能时网络错误:找不到指定的记录”

问题描述 投票:0回答:1

我有一个 Canvas 应用程序连接到本地 SQL Server 网关。连接成功,可以通过数据表预览查看记录。

我使用数据表下方的按钮导航到“编辑”屏幕,该屏幕将编辑数据表 (DT) 上选择的记录。表单已成功预加载 DT 数据,并且一切似乎都正常工作。但是,当使用具有

SubmitForm(form)
功能的按钮时,我收到错误

使用补丁功能时网络错误:找不到指定的记录。

没有成功,我尝试将

SubmitForm(FormName)
函数更改为 Patch。

尝试使用补丁编辑单个字段的示例:

Patch(OnPremiseSQLDB,dt_DataTable.Selected,
{Notes: DataCardValue46.Text}); 

同样的错误。

我花了两个多小时试图解决这个问题,但没有成功。

我打开监控并收到以下日志:

  1. 网络 - patchRow - 错误 - 未找到
{
  "status": 404,
  "duration": 74.39,
  "dataSource": "OnPremiseSQLDB",
  "responseSize": 54,
  "controlName": "btn_FormSave",
  "propertyName": "OnSelect",
  "nodeId": 7,
  "formulaData": {
    "script": "Patch(OnPremiseSQLDB,dt_DataTable.Selected,\r\n{Notes: DataCardValue46.Text})",
    "spanStart": 0,
    "spanEnd": 74
  },
  "data": {
    "context": {
      "entityName": "btn_FormSave",
      "propertyName": "OnSelect",
      "id": 13538,
      "nodeId": 7,
      "diagnosticContext": {
        "span": {
          "start": 0,
          "end": 74
        },
        "dataOperation": {
          "protocol": "cdp",
          "operation": "patchRow",
          "apiId": "/providers/microsoft.powerapps/apis/shared_sql",
          "dataSource": "UT_IVCustom",
          "table": "[dbo].[UT_IVCustom]",
          "operationName": "CdpConnector.patchRowAsync"
        },
        "formula": "Patch(OnPremiseSQLDB,dt_DataTable.Selected,\r\n{Notes: DataCardValue46.Text})"
      }
    },

  1. 功能 - 补丁 - 错误 -
{
  "status": null,
  "duration": null,
  "dataSource": null,
  "responseSize": null,
  "controlName": "btn_UT_IVCustomSave",
  "propertyName": "OnSelect",
  "nodeId": 7,
  "formulaData": {
    "script": "Patch(OnPremiseSQLDB,dt_DataTable.Selected,\r\n{Notes: DataCardValue46.Text})",
    "spanStart": 0,
    "spanEnd": 74
  },
  "data": {
    "errorMessage": "Network error when using Patch function: The specified record was not found.",
    "raiseToastNotification": false,
    "wasReported": false,
    "functionName": "Patch",
    "context": {
      "entityName": "btn_FormSavee",
      "propertyName": "OnSelect",
      "id": 13538,
      "nodeId": 7,
      "diagnosticContext": {
        "span": {
          "start": 0,
          "end": 74
        },
        "formula": "Patch(OnPremiseSQLDB,dt_DataTable.Selected,\r\n{Notes: DataCardValue46.Text})"
      }
    },
    "info": "Network error when using Patch function: The specified record was not found."
  }
}
powerapps powerapps-canvas powerapps-formula
1个回答
0
投票

您不必使用 ROWVERSION、Patch() 和 SQL。只需一个主键并打开 IDENTITY 就足够了。

但是,创建新记录时,您必须确保将 IDENTITY SEED 值设置为 NEXT 值。例如,如果 SEED 值较低或设置为 1,则可能会发生上面的 Patch() 错误。

--Find the next seed ID value and set it
DECLARE @NextIdentityValue INT;
SELECT @NextIdentityValue = IDENT_CURRENT('<<your table>>') + IDENT_INCR('<<your table>>');
DBCC CHECKIDENT ('<<your table>>', RESEED, @NextIdentityValue);
© www.soinside.com 2019 - 2024. All rights reserved.