Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

For-Loop only loads first row of Excel, rows are db names, used in connect string.

This is what I have so far, I am trying to make it get each row for the database column and pass it one by one to the connections string. But it picks the first one and connects to that first database and loads the same data over and over. How can I fix it so that it moves to the next row to pick the correct data from that database.


// fill variable with field values row by row

For i = 0 To NoOfRows('ANProjects')-1

  let vDatabaseName=peek('DatabaseName', $(i));

  let vProjectName=peek('ProjectName', $(i));

  trace $(vDatabaseName)  $(vProjectName);

  // .......... use connection string ???   // Added the new variable from the for loop.

  OLEDB CONNECT32 TO [Provider=ABCDEDB.1;Persist Security Info=True;User ID=BI_QLIKVIEW;Initial Catalog=$(vDatabaseName);Data Source=ABCD1P;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=00000;Use Encryption for Data=False;Tag with column collation when possible=False] (XPASsword is BLANK);


Note: My Table after this connects to a table name which is the same in each database. but each have different amount of row data in the sql database.

1 Reply
marcus_sommer

Generally will such a for each loop work. Are you sure that your table ANProjects has more than one row? Maybe your routine missed a disconnect-statement before going to the next loop-item.

- Marcus