I have the following problem: I need to check some numbers on a webpage. First I pass an identifier and then I have to check the results. Problem is, that there are not only different results but also a different amount of them.
So I searched the Forum and found that one part of my solution would be using an sql-server / database.
Actually I have one Table with the identifier and an unique ID to that

Table: dbo.DUS
Fields:DU_ID - the unique IDDU_TEXT - the identifier

which gives "the main loop" for the test.

And then a second one with the data to check, which creates the "sub-loop" beneath each "main loop"

Table: dbo.Timecodes
Fields:DU_ID - Linked to the unique ID above

Feldname Timecode } these three fields have to get verifiedBildname

I also created a stored procedure named dbo.usp_TimeCodesPerDU which accepts one parameter called @DU_IDPara. This basically does this:

Then I created an connector to my SQL-Database in Ranorex called SQL_TC_nach_DU.

Now I need to somehow use this data in my module. Actually I have successfully made an module which checks the data coming from that connection using the default-value for @DU_IDPara but I am somewhat stuck how to integrate the changing of the connection-string into my module.
I found some postings from @krstcs but was not able to follow him, I think because of him using some classes(?) or other elements in his codes that I don't have or know.

If anyone has a not too fancy code-snippet ideally with some explanations, that would be great!

Thanks in advance!

Best regards,
Frank

PS: If you need any informations to understand better what I want to do please let me know!

Each SQL Data Connector in Ranorex has a string property called "Query". All you need to do is change that query string to the SQL query you want to use the next time the connector is accessed by a connected test case.

Create a new Ranorex code module (you can use a recording module, but I use code modules so I don't have to work around the recording action table UI). Then add DU_ID as a module variable (right-click anywhere in the code and select "Insert New Module Variable"). You will bind this later.

Now, put the following code in the "Run()" method of the new code module, after the existing lines.

That's all the code you need. It updates the query string with the runtime value each time the parent test case loops, and then reloads the connector, refreshing the data for Ranorex to use the next time that data connector is referenced in a test case.

Now, drop this module into your test suite right above the test case that uses this data connector (I do it right above the related connector in order to make it easier to see the relationship).

I would recommend that you add a default value to @DU_IDPara in your stored procedure. I usually use 0 for int types. This will return no rows, but will still return the columns so you can bind the connector to your module variables without having the actual data.

If you have questions, feel free to PM me.

EDIT: Fix code issues

Last edited by krstcs on Tue Jun 28, 2016 2:09 pm, edited 1 time in total.