Unable to write to Azure SQL Database from PowerApps

BadatI 0 Reputation points
2024-06-20T15:31:32.7733333+00:00

I have a relatively simple PowerApp that writes a value to an Azure SQL Database along with the timestamp when it was written and some values from the Power BI Integration fields.

I previously had it writing to a sharepoint list and it ran fine. However I've not managed to get the app writing to the database. In the patch function, the data source is underlined but there isn't an error in the rest of the code. When hovering over the source, I get a tooltip saying that 'The function Patch has some invalid arguments'

I'm able to write to the table using the Query Editor, and whilst the PowerApp is able to read the dataset fine in a gallery which I tested, however is unable to write. Please help!

Azure SQL Database
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. BadatI 0 Reputation points
    2024-06-20T15:59:55.4366667+00:00

    I found the issue - the dataset didn't have a primary key!

    0 comments No comments

  2. GeethaThatipatri-MSFT 29,012 Reputation points Microsoft Employee
    2024-06-20T17:41:14.2466667+00:00

    @BadatI Great job identifying the issue! Thank you and very much appreciated for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue: You are facing an issue with writing data to an Azure SQL Database from PowerApps. The data source is underlined in the patch function, and you receive a tooltip saying that 'The function Patch has some invalid arguments'. you are able to read the dataset fine in a gallery but is unable to write to the table.

    Solution: As you mentoned you have resolved the issue as the dataset didn't have a primary key! Having a primary key is crucial for the integrity of your dataset and to ensure that each record is unique, which is essential for operations like Patch to work correctly in PowerApps. Now that you've added a primary key, your app should be able to write to the Azure SQL Database as expected.

    If you have any other questions or are still running into more issues, please let me know.

    Please remember to "Accept Answer" , so that others in the community facing similar issues can easily find the solution.

    Regards

    Geetha

    0 comments No comments