cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bowensby
New Member

SQL Server Database errors when offline and nothing hitting it

Below you will see the code the runs when the app starts to get data situated.  If you start the app when offline I get a SQL error but it shouldn't do anything if it isn't connected.  Any help/advice is appreciated. The error only happens for se.ctions and meters (DeliveryPoints).

 

 

 

 

 

If(Connection.Connected,
    ClearCollect(Sections, [@uvw_MeterReadings_Sections]);
    ClearCollect(Meters, [@uvw_MeterReadings_DeliveryPoints]);
    ClearCollect(CollectedReadings, Filter([@MeterReadingImport], 1 = 2));
    SaveData(Sections, "sectionList");
    SaveData(Meters, "meterList");
    LoadData(CollectedReadings, "collectedReadings", true);
    Set(DataLoadedDate, Now());
,
    Clear(Sections);
    Clear(Meters);
    Clear(CollectedReadings);

    IfError(
        LoadData(Sections, "sectionList", true)
        , 
        Notify("Error loading sections");
    );

    IfError(
        LoadData(Meters, "meterList", true)
        , 
        Notify("Error loading sections");
    );

    LoadData(CollectedReadings, "collectedReadings", true);
);

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
bowensby
New Member

Hi all,

I wanted to reply to my own post as I have learned more about this issue.  After much testing/debugging I found that even though I had the statement "If(Connection.Connected...." and the only lines that reached out the the DB were in the true part of that if it was still causing it to reach out to the database.  I opened a case with Microsoft and they agree it is worth looking into more.  Hopefully at some point they will figure something out and push out a fix. In the meantime if anyone else runs in to this I did come up with a way to fix it.  In my app I have refresh button that duplicated true part of the if statement.  I did this because the above code was running in the app start and couldn't fire the button off.  To fix my issue I moved the code above into a hidden timer on the home page.  I then removed the code in the true part of the If and replaced it with Select(RefreshButton) which fires the select even on the fresh button which runs the same code.  This separation kept the system from reaching out to the database when not connected. I can't explain it but at least it works.

 

Thank you and I hope this helps someone else!!

View solution in original post

2 REPLIES 2
alrez
Microsoft
Microsoft

Hi,

 

Everything looks correct to me. I'm not certain why exactly you are encountering this issue. I would recommend opening a ticket with Microsoft Support on this issue. I'll include a link below if you would like to go down this route. Otherwise if any other communities users have any ideas feel free to chime in.

 

If you would like to create a ticket with Microsoft Customer Support here is a link on how to do so: https://docs.microsoft.com/en-us/power-platform/admin/get-help-support

 

Regards,

 

Alex

 

-------

 

Community Support Team _ Alex Rezac
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

bowensby
New Member

Hi all,

I wanted to reply to my own post as I have learned more about this issue.  After much testing/debugging I found that even though I had the statement "If(Connection.Connected...." and the only lines that reached out the the DB were in the true part of that if it was still causing it to reach out to the database.  I opened a case with Microsoft and they agree it is worth looking into more.  Hopefully at some point they will figure something out and push out a fix. In the meantime if anyone else runs in to this I did come up with a way to fix it.  In my app I have refresh button that duplicated true part of the if statement.  I did this because the above code was running in the app start and couldn't fire the button off.  To fix my issue I moved the code above into a hidden timer on the home page.  I then removed the code in the true part of the If and replaced it with Select(RefreshButton) which fires the select even on the fresh button which runs the same code.  This separation kept the system from reaching out to the database when not connected. I can't explain it but at least it works.

 

Thank you and I hope this helps someone else!!

View solution in original post

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

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (94,564)