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

Notifications

Announcements

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

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)
  • 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.

     

  • 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.

  • 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
    );
  • Community Power Platform Member Profile Picture
    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

  • Verified answer
    v-micsh-msft Profile Picture
    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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 421

#2
WarrenBelz Profile Picture

WarrenBelz 365 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 339 Super User 2025 Season 2

Last 30 days Overall leaderboard