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

cant get the right format for SQL upload

Hi all,

I have the following issue:

On the first screen you can enter how many buildings there are. On another screen you select the building and enter additional information. The dropdown looks like this: Distinct(Filter(Objekt;EAP_Exists);Anz_Gebaeude)

After adding addtional info the field is written into a collection as gebaeude_id. the value is numeric.

 

And now the issue: when I try to load it into my SQL database I get the error, that the field content is not matching the content of the database field. No matter if I set the database field to VARCHAR or INT I get the same issue.

Text(gebaeude_id) is not working. Value(gebaeude_id) neither.

Powerapps can be really annoying sometimes

2 REPLIES 2
StalinPonnusamy
Super User
Super User

HI @DIECKBE 

 

We can Patch SQL in Multiple Ways. The below code Creates or Update the record

 

With(
    {
        item: LookUp(
            [@StudentTest],
            StudentID = Value(DataCardValue12.Text)
        )
    },
    If(
        IsBlank(item),
        Patch(
            [@StudentTest],
            {UserName: DataCardValue11.Text}
        ),
        Patch(
            [@StudentTest],
            LookUp(
                [@StudentTest],
                StudentID = BrowseGallery1.Selected.StudentID
            ),
            {UserName: DataCardValue11.Text}
        )
    )
)

 

 

 

Another approach to Update SQL, just passing ID without Lookup. In this Case StudentId is Primary Key

 

Patch(
    [@StudentTest],
    {
        StudentID: BrowseGallery1.Selected.StudentID,
        UserName: DataCardValue11.Text
    }
)

 

 

Another Approach using Lookup (Not passing Primary key)

 

Patch(
    [@StudentTest],
    LookUp(
        [@StudentTest],
        StudentID = BrowseGallery1.Selected.StudentID
    ),
    {UserName: DataCardValue11.Text}
)

 

  • Please share with me
    • how you are loading to SQL
    • The data type for the Primary column and other columns that trying to create or update


Thanks,
Stalin - Learn To Illuminate

DIECKBE
Frequent Visitor

Hey Stalin 🙂

With the following script, I create data in the database

ForAll(Seilanlage;
Patch('inspdeve.dim_seilanlagen';Defaults('inspdeve.dim_seilanlagen');

{
   ID: 0;
   Objekt_ID: BV_Konto.Result;
//   Gebaeude_ID: Gebaeude_ID.Text; <-- NOT WORKING
   Gebaeudeteil_ID: Value(Gebaeudeteil_ID);
   Gebaeudeteil_Beschreibung: Text(GebaeudeteilBeschreibung.Value);
   Gebaeudeteil_Dachflaeche: Dachflaeche_ID; 
    Hersteller_ID: Text(Seilanlagen_Hersteller_ID);
    Produkt_ID: Seilanlagen_Produkt_ID.Text;
    Seriennummer:Seilanlagen_Seriennummer;
    Seil_nr: Text(Seilanlagen_Seil_Nr);
    Stuetze_von:Seilanlagen_Stütze_von;
    Stuetze_bis:Seilanlagen_Stütze_bis;
    Laenge:Seilanlagen_Länge;
    Ueberfahrbar:If(Seilanlagen_Überfahrbar = "true";"Y";"N");
    Herstellungsdatum:Seilanlagen_Herstellungsdatum;
    Komponenten_ID:Seilanlagen_Komponenten_ID.Text;
    Komponenten_Anz:Seilanlagen_Komponenten_Anzahl;
    Standort: Text(SeilanlagenStandortText);
//    Standort_foto_file: STANDORT;
//    Standort_foto_text: Text(STANDORT);
    gueltig_von: Today();
    gueltig_bis: Date(2099;12;31);
    DELETED: "N"

 }));;

 

This field is causing issues: Gebaeude_ID.Text

Gebaeude_ID.Text is genreated here:

 

Collect(Seilanlage;{
   BV_Konto: BV_Kontonummer.Selected;
    Dachflaeche_ID:EAPDachflaeche_ID.Selected.Result;
    Gebaeudeteil_ID: LookUp('inspdeve.dim_gebaeudeteil'; gebaeudeteil_bezeichnung = SeilanlagenGebaeudeteilDropDown.SelectedText.Value;gebaeudeteil_ID);

 

any more questions? Let me know 🙂

Thanks in advanced and best regards from Germany

 

Benny

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,117)