Newbie-Filling a table but selected fields

Discussion in 'Questions (Windows Mobile)' started by enonod, Oct 12, 2007.

  1. enonod

    enonod Well-Known Member Licensed User

    Q1...
    I am trying to get going with SQL and a table. I notice the simplicity of filling the table with a single command 'TableExecute'.
    However I wish to fill the table but only with 2 of the several fields. Is there a way to do this (and not necessarily in the order the fields appear in the Database Table), fairly simply please?

    Q2...
    There appear to be no equivalents to 'AbsolutePosition' etc as used in ADO, to enable keeping track when loading say a page at a time from a long database table. Have I missed something?

    Thanks in advance
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    A1: You can use any SELECT query with ExecuteTable.
    If you want to show 2 fields:
    Cmd.CommandText = "SELECT field1, field2 FROM table1"
    Cmd.ExecuteTable(...)
    A2: You can use the built-in SQLite row index ROWID.
    It is always available.
    Cmd.CommandText = "SELECT field1, field2 FROM table1 WHERE ROWID > 50 AND ROWID <70"
    Cmd.ExecuteTable(...)
     
  3. enonod

    enonod Well-Known Member Licensed User

    That is wonderful thank you Erel. I somehow thought that the whole database table would be loaded into the table object. It is obvious now you have explained.
     
  4. enonod

    enonod Well-Known Member Licensed User

    Sorry to be a nuisance.
    Well it did seem obvious. I have achieved as you suggested.
    However I didn't explain well enough. I require the whole table of data to be accessed, but, I only want to 'display' two fields, whilst being able to refer to the others.
    A tiny bit more help would be appreciated.
     
  5. agraham

    agraham Expert Licensed User

    You could load all the data you want to access into a second table that is not visible.
     
  6. enonod

    enonod Well-Known Member Licensed User

    Why does every answer make me feel simple?
    Great idea, thank you agraham for some lateral thinking.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    You could also hide the unwanted columns by setting their width to 0.
     
  8. enonod

    enonod Well-Known Member Licensed User

    Thank you Erel, for another good suggestion. Spoilt for choice.
     
Loading...