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
Frequent Visitor

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
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (54,273)