Welcome! Log In Create A New Profile

Advanced

Programmatically Loading A Table Via A Query WIth Parameters

Posted by VazCro 
I'm relatively new to WinDev, with release 14. I am an ex-Clarion programmer. Now, with an application needing a whole new makeover, I am finding that WinDev seems best for the job.

I am trying to load a table programmatically with a query that has parameters. I have verfied that the parameters are being captured correctly and the table is loading. It uses NAME as the search WHERE NAME LIKE...... The table fills with the records matching my name pattern. And this is where the problem starts.

As I scroll down, I begin to see other records that are not matches. I also see that the names are not sorted in order of REGION, DISTRICT and NAME. In fact, I find that all records from this table have been loaded.

This is a memory table. The code that I created for a button that processes a COMBO control for status and an EDIT control for name pattern is as follows:
___________________________________________________________________
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
___________________________________________________________________-
I'm doing something wrong. I think it has to do with the HExecuteQuery and the LOOP that follows.

Really need help on this. Thanks
VazCro,


On Setting the Parameters:
QRY_Query1.Param1 = COMBO_Status..Displayedvalue
QRY_Query1.Param2 = EDT_Criteria
you do not need to add them again on the HExecute
just use HExecuteQuery(YourQueryName)

To Loop thru a query and add lines to a table for ever record of the query.

//Execute your query
HExecuteQuery(YourQueryName)

//Point to the first record of he query
HReadFirst(YourQueryName)


//Start loop that will end when there are no more records in the query to read.
While Not HOut(YourQueryName)

//Add you line to the table

//Move to the next record in the query
HNext(YourQueryName)

End



Edited 1 time(s). Last edit at 07/03/2009 02:36AM by Dennis W.
Do not forget

HCancelDeclaration(YourQueryName) at the end of the procedure

DerekT
VazCro,

In line 1 of your code instead of writing TableDeleteAll(TABLE_Table1)
it may be better to use -

HCreation(TABLE_Table1) as this recreates a new and blank table.

Milton
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: