web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / can't Write data on Sq...
Power Apps
Answered

can't Write data on Sql server table

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello everyone

I'm tring to read from Textbox and store it on sql server table....

 

I used function patch it gave me an Error

https://imgur.com/a/HxDh9

 

Patch('[dbo].[KAfaween]',Defaults('[dbo].[KAfaween]'),{Name: "hhhhhhhhhh"})

the first argumnt of 'Patch' must be a collection 

 

 

how can I insert into sql table a value...?

 

Categories:
I have the same question (0)
  • Verified answer
    v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    I just tested the patch() function, it works for creating new record into SQL Server database from my side.

    Please take a note that when using the following code:

    Patch(DataSource, Defaults(DataSource), {PrimaryKey:Required, OtherFields:UpdateValue})

    The Primary Key is a required field (If it has not been set to be auto-generated from the Server side).

     

    Adding the function reference:

    Patch function in PowerApps

     

    Regards,

    Michael

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    man thanks... it worked

    I think this is a littele dummy.. is how it gives you an error if the table doesn't have a primary key..

     

    this is strange...

    any way thanks a lot

  • Brian Dang Profile Picture
    3,976 on at

    Confirmed: I had this same error and it was because I did not correctly configure my SQL table. I had included IDENTITY(1,1), but not PRIMARY KEY.

     

    I recreated my table using this generic structure:

     

    CREATE TABLE Persons (
     ID int IDENTITY(1,1) PRIMARY KEY NOT NULL,
     LastName varchar(255) NOT NULL,
     FirstName varchar(255),
     Age int
    );
  • mcorsaaiincs Profile Picture
    15 on at

    I have a similar issue.  My SQLServer table has a primary key, and I've been able to write to it and read from it already.  But the connection occasionally seems to stop working.  The only solution I've found is to remove the connection entirely and then add it back in.  It appears to be a bug.  One other detail: there is no error message or indicator from PowerApps that the connection stopped working.  That's part of the major problem with this.  And all connections (Internet, Gateway, etc.) are showing that they work fine still.

  • mcorsaaiincs Profile Picture
    15 on at

    Actually, I found out that my On_Submit button function had an error before this issue happened.. It was not showing as an error, though, until I went into the function itself.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 529 Most Valuable Professional

#2
Haque Profile Picture

Haque 230

#3
Kalathiya Profile Picture

Kalathiya 217 Super User 2026 Season 1

Last 30 days Overall leaderboard