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 / Issue updating multipl...
Power Apps
Unanswered

Issue updating multiple gallery items to SQL in Power Apps

(0) ShareShare
ReportReport
Posted on by 7
Hi All,

I’ve been stuck on this for the past seven days and would really appreciate your help.

I need to update multiple rows in a SQL table directly from a Power Apps gallery. Each gallery item contains three ComboBox controls and three TextInput controls. I’m looking for the correct approach (and formula) to save all edited items in the gallery back to SQL in one go.

 
App Onstart:
 
ClearCollect(colAllChannel,'GPS.sql_channel');
 
 
Gallery items:
 
colAllChannel
 
My button onselect:
ForAll(
    colAllChannel As r,
    Patch(
        'GPS.sql_channel',
        LookUp('GPS.sql_channel', ID = r.ID),
        {
            Textinput 1: Value(r.Textinput 1),
            Textinput 2:Value(r.Textinput 2)  
         
        }
    )
)   // here ID is primary key
  
I’m trying to update multiple rows in SQL from my Power Apps gallery, but none of the rows are getting updated. I keep getting an error, and I can’t figure out why. Could someone please help me understand what might be causing this?
 
Please provide correct code. Thanks for your help
Categories:
I have the same question (0)
  • Kalathiya Profile Picture
    741 on at
    @HK-21101814-0,  

    It looks like the logic is correct. However, when using a SQL data source, make sure the table has a primary column. otherwise, Power Apps won’t support write operations like Patch/update.

     
    If you are creating new record then your syntax will be: 
    ForAll(
        colAllChannel As r,
        Patch(
            'GPS.sql_channel',
            Defaults('GPS.sql_channel'),
            {
                'Textinput 1': Value(r.'Textinput 1'),
                'Textinput 2':Value(r.'Textinput 2')  
             
            }
        )
    )
    If you are updating the record then:
    ForAll(
        colAllChannel As r,
        Patch(
            'GPS.sql_channel',
            LookUp('GPS.sql_channel', ID = r.ID),
            {
                'Textinput 1': Value(r.'Textinput 1'),
                'Textinput 2':Value(r.'Textinput 2')  
             
            }
        )
    )
     
    If you are still facing an error, Please share the error details.
     
     
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
     
  • HK-21101814-0 Profile Picture
    7 on at
    Hi @Kalathiya actually SQL column and textinput names are correct. For your reference I just provided in that way. Could you please give me the correct code please. Actually the logic may be incorrect
  • Kalathiya Profile Picture
    741 on at
    Hello @HK-21101814-0
     
    Please try below code: 

    If your SQL column name contains spaces, make sure to wrap it in single quotes while patching.

    ForAll(
        colAllChannel As r,
        Patch(
            'GPS.sql_channel',
            LookUp('GPS.sql_channel', ID = r.ID),
            {
                'Textinput 1': Value(r.'Textinput 1'),
                'Textinput 2':Value(r.'Textinput 2')  
             
            }
        )
    )

    If the above solution still doesn’t work, please share a screenshot of your collection output, your SQL table structure, and the exact error message you are getting.

    That information will help us troubleshoot the issue further and give you a more accurate solution.

    Hope this helps 👍

    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
    ---------------------------------------------------------------------------------
     
    📩 Need more help? Mention @Kalathiya anytime!
    ✔️ Don’t forget to Accept as Solution if this guidance worked for you.
    💛 Your Like motivates me to keep helping!

     

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 401

#2
WarrenBelz Profile Picture

WarrenBelz 334 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 325 Super User 2025 Season 2

Last 30 days Overall leaderboard