Forum Discussion

dgentle's avatar
dgentle
Occasional Visitor
13 years ago

How to put values in TableVariable using SQL Query

I am trying to populate a TableVariable object using SQL in a script.  But the results of my script result in only one row being populated in my TableVariable.  I need two rows in this particular case.  The following is what I have so far.  Any recommendations on what I need to change/correct in my script?  Thanks in advance.










Sub SQLGetClientNames




  Dim Conn, Rs, indx


  Set t = ProjectSuite.Variables.ClientNameKey


   




  Set Conn = CreateObject("ADODB.Connection")


  Conn.ConnectionString = projectsuite.Variables.DBConnectionString


  Conn.Open


  Set Rs = Conn.Execute("select DescrWithClientNo, ClientKey from vw_ClientList where DescrWithClientNo is NOT NULL") 




                




  ' Processes data




  Rs.MoveFirst


  indx = 1




  While (Not Rs.EOF) and (indx < 3)





    'Writes query values to the ClientNameKey Table


    t.Iterator.Value("ClientName") =  Rs.Fields.Item("DescrWithClientNo").value    


    t.Iterator.Value("ClientKey") =  Rs.Fields.Item("ClientKey").value  




    'List the values written to ClientNameKey Table


    Log.Message t.Iterator.Value("ClientName") & " - " & t.Iterator.value("ClientKey")


 


    Rs.MoveNext


    indx = indx + 1     




  WEnd


      


  Rs.Close 


  Conn.Close


  Set Rs = Nothing


  Set Conn = Nothing


 




  'List the values in the ClientNameKey Table


  Call ProjectSuite.Variables.ClientNameKey.Iterator.Reset


  While not ProjectSuite.Variables.ClientNameKey.Iterator.IsEOF


   Log.Event ProjectSuite.Variables.ClientNameKey.Iterator.value("ClientName")


   ProjectSuite.Variables.ClientNameKey.Iterator.Next


  WEnd


     


End Sub

No RepliesBe the first to reply