RetroCoder
RetroCoder

Reputation: 2685

How do I retrieve the actual query directly from a ADODB.Recordset?

I'm using a command to create a new record set:

set rsQuery = Server.CreateObject("ADODB.Recordset")

Once the rsQuery.open command is performed, how do I determine which query was fired by only looking at the Recordset or rsQuery object? The reason I need to do this is b/c I may have many case statement that open a querystring based on a case. Not only do I want the result from the query, I just want to print out the query without having to create a response.write command for each query command.

example:

case "1"
  rsQuery.open "Select * from tblA", conn
case "2"
  rsQuery.open "Select * from tblB", conn

etc...

Desired Result: response.write "My Result:" & rsQuery.Query?

My Result: Select * from tblA

Upvotes: 1

Views: 355

Answers (2)

RetroCoder
RetroCoder

Reputation: 2685

Use Source method:

response.write "My Result:" & rsQuery.Source

Upvotes: 1

Dee
Dee

Reputation: 1420

you could do this:

case "1"
  myquery = "Select * from tblA"
case "2"
  myquery = "Select * from tblB"

...
  rsQuery.open myquery , conn
  response.write myquery 

Upvotes: 2

Related Questions