Thursday, July 2, 2009

Filling A Table Programmatically Using A Query

link : http://forum.pcsoft.fr/thread.awp?groupid=pcsoft.us.windev&postid=195981&cur=195981&lang=en-us&v=2

Thank you for your answer. I did as you suggested and made sure that the combo control value and the edit control value are being seen. They are.

The code in the button is set to execute a query. It clears the table, sets up the parameter values, executes the query and loads the table. However, I see that the table has the names requested using a LIKE but it is not sorted by region, district and name as requested. As I scroll farther down, I see that actually ALL the records (including those not requested) have been loaded. I am selecting based upon PARAM1 (status of Activo, Inactivo or Pasivo) and PARAM2 (name entered to match a LIKE pattern).

The button's code is as follows:
CODE
TableDeleteAll(TABLE_Table1)
Subscript is int
Str is string
Subscript = ListSelect(COMBO_Status)
Str = COMBO_Status[Subscript]
QRY_Query1.Param1 = Str
QRY_Query1.Param2 = EDT_Criteria
Info(QRY_Query1.Param1)
Info(QRY_Query1.Param2)
HExecuteQuery(QRY_Query1,MyConnection1,QRY_Query1.Param1,QRY_Query1.Param2)
HReadSeek(students,nombre,EDT_Criteria)
IF HFound(students) THEN
SUB is int = 1
LOOP
TableAddLine(TABLE_Table1,students.reckey,students.nombre,students.fecha_nac,students.registro,students.fecha_regi,students.regiones,students.distrito,students.referidopor,students.status)
HReadNext(students,nombre)
IF HOut(students) = True THEN
BREAK
ELSE
TableAddLine(TABLE_Table1,COL_Column1,COL_Column2,COL_Column3,COL_Column4,COL_Column5,COL_Column6,COL_Column7,COL_Column8,COL_Column9)
SUB += 1
END
END
END
/CODE

The query is as follows:
SELECT
students.reckey AS reckey,
students.nombre AS nombre,
students.fecha_nac AS fecha_nac,
students.registro AS registro,
students.fecha_regi AS fecha_regi,
students.regiones AS regiones,
students.distrito AS distrito,
students.referidopor AS referidopor,
students.status AS status
FROM
students
WHERE
students.status = {Param1}
AND students.nombre LIKE {Param2}%
ORDER BY
reckey ASC,
distrito ASC,
nombre ASC

Why am I getting everything in the table?

Thanks for your help.
Vince

No comments:

Post a Comment