cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RhysD
Frequent Visitor

Patching to SQL: data types wont match up

Hi all, 

 

Hope all's well. I'm working on a power app at the moment where I'm patching some data from and to a SQL table, the problem I'm having is that the patch throws back an error saying that the data type is wrong.

 

I've tried changing the data type directly within the patch by using Value() and DateValue(), but that didn't seem to work. I also tried changing the datatype and associating it with local local variables, which I then used in the patch, but that didn't seem to work either.    

 

Ie. Patch(Source, {Date: DateValue(SourceDate), Number: Value(SourceValue)})

 

Any idea's as to what might be wrong? 

 

All the best!

Rhys. 

4 REPLIES 4
Pstork1
Dual Super User
Dual Super User

SQL has a number of Date and Number data types.  What specific data type is the field in SQL.  Not all of them are compatible with Power Apps.  Also, normally you need a second parameter on the Patch to specifically identify the SQL record you are updating.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
RhysD
Frequent Visitor

Thanks, that gave me a much better lead. I've managed to get past the original error now by double checking the record that was put in, however I now have another error.

The table it's going into requires a text field filled out that isn't within the form, it's effectively a default value that's needed for each entry, I've tried to supply the value directly but it's still saying that it requires data. Any ideas? It doesn't specify that the data type is wrong, just that it can't see it.  
(formatting below).

RhysD_0-1621592622603.png

mogulman
Impactful Individual
Impactful Individual

Is this Azure SQL?  It is correctly formatted.  I have a similar field.

 

ErrorMessage: "",

 

Defined by

[ErrorMessage] [varchar](256) DEFAULT('') NULL,

 

I would create an INSERT statement that duplicates the Patch and run it from SSMS.  It is possible you are not fully defining the data required to insert data.

 

If this is on-premise SQL Server run SQL Profiler and see what is going on.

RhysD
Frequent Visitor

weirdly enough, when I add in the AuditSource twice is throws back an error saying it's already been defined:

RhysD_0-1621598801066.png

My colleague thinks it's a formatting error, but we're both a bit stumped with it.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,601)