cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TML
Level 8

Collection using local sql - data types

I have an app that Collects data from a local Gateway SQL table into a Powerapps collection. When I try to add a new row to the collection, I get an error that the data types do not match.

1.jpg

I have narrowed it down to a date field.  If I export the app and view the JSON Entities file, it shows me that when I collect from SQL, the date field has a data type of "lowercase d".  However, when I try to Collect and add a new row to the collection, the data type is "uppercase D".  I have tried many things... changing the datatype in SQL from datetime to: date, datetime2, and dateoffset.  On the PowerApps side, I have tried using the date control's SelectedDate, using a string, using the DateValue of a string.  Obviously the string won't work, but the other two both have a data type of "uppercase D".

2.jpg

 

When trying to update from Collection inside of PowerApps, this is the data type:

3.jpg

I cannot get anything to update the collection. What am I missing or not understanding?

 

Any help is greatly appreciated.

 

5 REPLIES 5
Community Support Team
Community Support Team

Re: Collection using local sql - data types

Hi @TML,

 

How do you create the collection within your app?

Further, how do you add a new row to the collection that you created? Could you please share a bit more about the formula within your app?

 

I have made a test on my side, and don't have the issue that you mentioned.

 

The error message told that there is a data type mismatch issue within the formula that you use to add a new row to the connection. The DateReporting column is a datetime type column, but the dteReportingDate.SelectedDate formula returns a Date value.

 

Please take a try to format the date value (dteReportingDate.SelectedDate) that you provided for the DateReporting column into a datetime value, and then check if the issue is solved.

 

Please take a try to modify your formula as below:

Collect(
Collection1,
{
CareTaker:"",
Comments:"",
DateReporting:DateTimeValue(Text(dteReportingDate.SelectedDate)),
FarmCode:"",
...

}
)

Note: The Collection1 represents the Collection that you created within your app, which collects data from your local Gateway SQL table.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
TML
Level 8

Re: Collection using local sql - data types

When the app's first screen opens, it reads in existing data from the SQL table.  Below is the code:

 ClearCollect(
DCIRecords,
SortByColumns(
Filter(
AddColumns(
'[dbo].[DCI]',"NeedsSync",false),
FarmCode=gFCode),
"DateReporting",
Descending));

 

Later in the app when it is determined that I need to add a row to the Collection, I use this code:

Collect(DCIRecords,
    { FCode: gFCode,
    DateReporting: DateValue(vSelectedDate),
    Room: vRoom,
    HighTemp: vHTemp,
    LowTemp: vLTemp,
    TempSetPoint: vTempSetPt,
    WaterMeterUsage: vWaterUsage,
    Comments: vComments,
    NeedsSync: gNeedsSync
    }
);

I have also tried using dteReportingDate.Selected date and either way it give me the same outcome.  I have also changed the data type in the SQL column and have tried DateTime, DateTime2, Date, and DateOffset.  All have the same outcome and think their is a data type mismatch.

 

TML
Level 8

Re: Collection using local sql - data types

Is there documentation that explains the letter codes for the different data types?

TML
Level 8

Re: Collection using local sql - data types

I also tried just now using DateValue and the string date, and concatenated a time to it as well and still have the same results.

TML
Level 8

Re: Collection using local sql - data types

Does this mean no one can answer the question or help me solve the problem?

Helpful resources

Announcements
thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,251)