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 / SQL connector is very ...
Power Apps
Unanswered

SQL connector is very slow. Patch function.

(0) ShareShare
ReportReport
Posted on by 2

Hi, I have the following problem with the SQL Server connector. I want to use the patch method to insert new records into the database, I tried using the Patch with a For All on a list, but this way is very slow. I read on the forum another option, which is using the same method but with 2 arguments: Patch(Datasource; Collection) but I always get 2 errors. The first is that if I pass the id field, I get the message "id is mandatory" and if I don't pass it, it throws another error "record not found". Can you please suggest any solution?

 

Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @WilliamsSA 

    I don't have experience with sql but with SharePoint and Dataverse.  Start by making an empty collection from the datasource fields and then removing the blank first record. This can be done as the OnSelect property of a button or in the OnVisible property of the screen.

     

    Collect(collection, Defaults(datasource); //will create a collection with a blank field
    Clear(collection) // removes the blank field and just leaves the column heads

     

    This will create an empty collection with all the fields.  Then as you add records to the collection, say from a gallery using

     

    Collect(collection, {ID:ThisItem.ID, LastName:Textinput2.Text, Status:Combobox1.Selected.Status...)

     

    Note the ID:ThisItem.ID must be in the list along with the fields to be modified.

    To add the collection to the datasource, a button with OnSelect: Patch(datasource, collection) will modify the records in the datasource using the data in the collection.

    To add a new record, first, a new blank record can be added to the datasource with with:

    Collect(collection, Defaults(collection) and should be assigned an ID automatically by SQL. 

    That blank record, just added, should now have an ID and can then be modified  as in the formula above.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard