Locked databinding with complex primary key

  • martes, 05 de junio de 2012 7:03
     
      Tiene código

    How to bind a ComboBox to a Composite Foreign Key?

    I want to bind a ComboBox by a Composite Key:

    Tables MARC and T001L are connected by a composite key:

    In the front end I don't find a possibility to map a composite foreign key. I only can set one field (here LGORT):

    To filter the values depending to the WERKS-part of the composite key I did set a filter:

        private void mARCBindingSource_CurrentChanged(object sender, EventArgs e)
        {
          string Filter = "";
     
          if ((sender as BindingSource).Current != null)
          {
            DataSet.MARCRow row = (((sender as BindingSource).Current as DataRowView).Row as DataSet.MARCRow);
            string myWERKS = row.WERKS;
            Filter = string.Format("WERKS = '{0}'", myWERKS);
          }
     
          t001LBindingSource.Filter = Filter;
        }

    Database Values are:

    T001L:
    mandt werks lgort lgobe
    100 1200 390 Lacklager AL
    100 1200 550 Paletten
    100 1200 580 Schrott
    100 1200 600 Druckvorstufe
    100 1200 770 Aussenlager
    100 1200 800 Verpackung
    100 1260 1000 Allgemein
    100 1300 100 Rohmaterial
    100 1300 1000 Allgemein
    100 1300 1100 IN
    100 1300 1200 Prod Hamburg
    100 1300 200 Fertigmaterial
    100 1300 300 Druckfarbe Tube
    100 1300 380 Lacklager
    100 1300 450 Verschraub/Folie
    100 1300 550 Paletten
    100 1300 590 Kunstoffabfall
    100 1300 600 Druckvorstufe

    MARC:
    MANDT MATNR WERKS VSPVB LGPRO
    100 A000022 1200 BEREICH1 NULL
    100 A000022 1300 Bereich2 550

    This means that when selecting the second record in MARC the ComboBox should show "Paletten" (=550).

    But it does show „Kunstoffabfall“ (590)!



    • Editado Charly_S martes, 05 de junio de 2012 7:04
    • Editado Charly_S martes, 05 de junio de 2012 7:08
    •  

Todas las respuestas

  • miércoles, 06 de junio de 2012 7:31
     
     

    Hi Charly,

    Try to just set one foreign key, You have already set three cloumns.

    Have a nice day.


    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

  • miércoles, 06 de junio de 2012 11:43
     
     

    Unfortunately I can not change the foreign keys in the database since I am reading from an SAP database.

  • jueves, 07 de junio de 2012 8:13
     
     

    Hi Charly,

    Would you like to post your test project here with test data?

    Forgive me, I am lazy but I am really want to help you as far as I can, believe me.

    Have a good day,


    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.