Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL quering - how to use results of one query in the following one
#8
Solved: 11 Years, 3 Months, 3 Weeks ago
I have unworking solution, perhaps you can advise me how to correct it? I am getting Type Mismatch run error in red row. Perhaps you can help me to indicate exact cell from which I need a value?



Code:
Dim Conn
Dim Rs
Dim strQuery
Set Conn = CreateObject("ADODB.Connection")
Set Rs = CreateObject("ADODB.Recordset")
strQuery = "Select column from table where USERID = 'testuser"
Rs.CursorType = 1
Conn.Open "Driver={Microsoft ODBC for Oracle};Server=myserver.com;Uid=user;Pwd=pwd;"
Rs.Open strQuery, Conn
Recordcount = Rs.RecordCount
DataTable.GlobalSheet.AddParameter "column",""

While (NOT Rs.EOF)
For i=1 to Recordcount
DataTable.SetCurrentRow(i)
DataTable("WKF_ORDER_ID",DtGlobalSheet) = Rs.Fields("WKF_ORDER_ID")
Rs.MoveNext
Next
Wend
Conn.close
Set Conn = Nothing
Set Rs = Nothing

Dim Conn2
Dim Rs2
Dim strQuery2
Set Conn2 = CreateObject("ADODB.Connection")
Set Rs2 = CreateObject("ADODB.Recordset")
[color=#FF0000]strcolumn DataTable.Value("column")[/color]
strQuery2 = "select * from table2 where USERID_R = 'test2' and AUDITCOLUMN = '" & strcolumn & "'"
Rs2.CursorType = 1
Conn2.Open "Driver={Microsoft ODBC for Oracle};Server=myserver.com;Uid=user;Pwd=pwd;"
Rs2.Open strQuery2, Conn2

Recordcount2 = Rs2.RecordCount
DataTable.GlobalSheet.AddParameter "REQUEST_COMPONENT", ""

While (NOT Rs.EOF)
For i=1 to Recordcount2
DataTable.SetCurrentRow(i)
DataTable("REQUEST_COMPONENT",DtGlobalSheet) = Rs.Fields("REQUEST_COMPONENT")
Rs.MoveNext
Next
Wend

Conn.close
Set Conn = Nothing
Set Rs = Nothing
Reply


Messages In This Thread
RE: SQL quering - how to use results of one query in the following one - by unbeliever - 01-12-2010, 05:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Rolleyes Browse object query Hema a newbie 0 1,800 07-22-2014, 08:37 PM
Last Post: Hema a newbie
  SQL Query Issue in QTP rajiv.qtp 1 2,476 11-28-2013, 10:36 AM
Last Post: Jay
  Exporting QTP runtime datatable to SQL server during SweetyChowdhury 1 3,252 05-10-2013, 03:41 AM
Last Post: sria123
  SQL on oracle database doesn't return a value Bluefields 2 3,234 07-09-2012, 01:23 PM
Last Post: Bluefields
  Do recordsets get to use only ONE query? Arena 0 2,184 04-03-2012, 07:08 PM
Last Post: Arena

Forum Jump:


Users browsing this thread: 3 Guest(s)