cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jpyszkowski
Regular Visitor

Patch function to SQL table with Identity ON.

Hello,

 

I am trying to develop a simple app that allows me to update values in a SSMS table. The column id_num is set to Identity yet I still get the error that my Datasource needs to be a collection. Can Powerapps directly update a SQL server table? Do I need to update the collection first and then send those updates to SQL?

 

Any help is appreciated. Thanks.

image.pngimage.png

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User III
Super User III

Hi @jpyszkowski 

I think this is because your id_num isn't set as a primary key. If you right click the id_num column in SSMS (in the top part of the grid in your second screenshot), there should be an option to set the column as primary key.

After you do this in SSMS, you'll need to refresh the datasource in PowerApps. There have been some cases in the past few weeks where it's taken some time for such changes to take effect, but this should hopefully solve your problem.

View solution in original post

4 REPLIES 4
timl
Super User III
Super User III

Hi @jpyszkowski 

I think this is because your id_num isn't set as a primary key. If you right click the id_num column in SSMS (in the top part of the grid in your second screenshot), there should be an option to set the column as primary key.

After you do this in SSMS, you'll need to refresh the datasource in PowerApps. There have been some cases in the past few weeks where it's taken some time for such changes to take effect, but this should hopefully solve your problem.

View solution in original post

@timl Thank you much. Took about 5 mins for powerapps to refresh and pick up that change.

You're welcome, glad that solved the problem.

vakula
Helper I
Helper I

I have a created a table in sql database with one column Id as Identity(1,1). Please let me know what value should be passed to the patch for Id Column.

Patch(
'[dbo].[Data]',
Defaults('[dbo].[Data]'),
{
Id: ??? (What should be passed here)

Name :DataCard_Name.Selected.Result})

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (19,460)