Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FYI; Problem with PADL; .NULL. in SELECT SQL
Message
De
23/06/2009 10:31:16
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/06/2009 09:41:11
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01407500
Message ID:
01407791
Vues:
44
>Cetin,
>
>beg your pardon, somehow I do not see what you are talking about.
>
>My limited knowledge of comboboxes:
>
>BoundColumn is the PK in the table (curPick) that fills the combobox while controlsource holds a refernce to the FK of an other table (curWork).
>
>If I change Record in curWork the combobox show the value coresponding to the record in curPick with PK=curWork.FK
>
>If I alter comboboxes value the combo will do internal REPLACE curWork.FK with curPick.PK
>
>And both FK and PK have to be character
>
>this is all what I know about it.
>
>Ok one can have one column in the combo (.ColumnCount = 1). Lets hope .BoundColumn = 1 means the first column of my underlying table (the position where my DBCS creates tables PK)
>
>But this is not my problem
>
>I have a key into my database. This is of type integer. I need to translate this into a character first, to use it as BOUNDCOLUMN.
>Your example uses samples/data/orders.Emp_id. Emp_id is a character anyway, so it needs no tranlsation.
>
>So what are you trying to express?
>
>Agnes

Agnes,
It seems like you know combos partially wrong.
What I am saying is:

You don't need to query any column's value from the combox itself (in combo all columns are character). You can directly query underlying source using old plain alias.field without any conversion.

In case of ControlSurce binding you know it wrong that you should convert to character. You don't need to, combo does that already even if it were needed. But if you a have a numeric as a BoundColumn then be sure to set BoundTo = .T. Otherwise the numeric value acts as a listindex rather than a key value.

Here is another sample:
Public oForm
oForm = Createobject('comboSample')
oForm.Show

Define Class comboSample As Form
  Top = 0
  Left = 0
  Height = 350
  Width = 620
  DataSession=2

  Add Object grdItems As Grid With ;
    Height = 300, ;
    Left = 10, ;
    Top = 10, ;
    Width = 600, ;
    Rowheight = 19,;
    RecordSource = "crsItems"

  Procedure Load

    Select Cast(.Null. As Int) As ProductID, Cast('' As c(50)) As prod_name ;
      FROM (_samples+'Data\products') ;
      UNION ;
      select Int(Val(product_id)) As ProductID,prod_name ;
      FROM (_samples+'Data\products') ;
      INTO Cursor crsProducts ;
      readwrite
    Index On ProductID Tag ProductID

    Create Cursor crsItems ;
      (LINE_NO i, ORDER_ID c(6), ;
      ProductID i Null, UNIT_PRICE Y, QUANTITY i)

    Insert Into crsItems ;
      Select LINE_NO, ORDER_ID, ;
      Val(product_id) As ProductID, ;
      UNIT_PRICE, QUANTITY ;
      From (_samples+'data\orditems')
    locate  

    Use In 'products'
    Use In 'orditems'

  Endproc

  Procedure grdItems.Init
    Local ix
    With This
      For ix = 1 To .ColumnCount
        If Upper(Justext(.Columns(m.ix).ControlSource)) == 'PRODUCTID'
          With .Columns(m.ix)
            .Bound = .F.
            .ControlSource = "(Iif(Seek(crsItems.productid,"+;
              "'crsProducts','productID'),crsProducts.prod_name,''))"
            .Width = 180
            .Alignment = 0
            .AddObject('comboincol','combobox')
            With .ComboIncol
              .BoundColumn = 2
              .BoundTo = .T.
              .ColumnCount = 2
              .ColumnWidths = "180,0"
              .RowSourceType = 3
              .RowSource = "select prod_name,productID"+;
                " from crsProducts"+;
                " order by 1" +;
                " into cursor crsComboSource"
              .SpecialEffect = 1
              .Style = 2
              .ControlSource = "crsItems.productID"
              .Visible = .T.
            Endwith
            .CurrentControl = 'comboincol'
          Endwith
          Exit
        Endif
      Endfor
      .AddColumn(.ColumnCount+1)
      .Columns(.ColumnCount).Name = 'showProdID'
      .ShowProdID.ControlSource = '(crsItems.ProductID)'
    Endwith
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform