Recover SQL string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MillerPr
    New Member
    • Feb 2008
    • 1

    Recover SQL string

    Hi

    I would like to know if there is an an easy way to recover the entire SQL string sent to the SQL server built using ADO adparam methods.
    I need to recover and assign to a variable the entire SQL string executed by objCmd.Execute below

    Thanks

    example

    'Declare database objects
    Dim objConn As New ADODB.Connectio n
    Dim objCmd As New ADODB.Command
    Dim objErr As ADODB.Error

    'Establish a database connection using SQL server Authentication
    objConn.Open "DSN=DSNname;UI D=sa;PWD=passwo rd;DATABASE=DBn ame"

    'Check the state of the connection to ensure we are connected
    If objConn.State = adStateOpen Then

    'Set the Command object properties
    Set objCmd.ActiveCo nnection = objConn
    objCmd.CommandT ext = "spExportGr oup"
    objCmd.CommandT ype = adCmdStoredProc

    'Set the Command object parameters
    objCmd.Paramete rs.Append _
    objCmd.CreatePa rameter("LastNa me", adVarChar, adParamInput, 80, LastName)

    objCmd.Paramete rs.Append _
    objCmd.CreatePa rameter("FirstN ame", adVarChar, adParamInput, 80, FirstName)

    objCmd.Paramete rs.Append _
    objCmd.CreatePa rameter("Compan yName", adVarChar, adParamInput, 80, CompanyName)

    objCmd.Paramete rs.Append _
    objCmd.CreatePa rameter("GuestT ype", adVarChar, adParamInput, 20, GuestType)

    objCmd.Paramete rs.Append _
    objCmd.CreatePa rameter("EmailI D", adVarChar, adParamInput, 250, EmailID)

    objCmd.Paramete rs.Append _
    objCmd.CreatePa rameter("Semina rID", adVarChar, adParamInput, 20, SeminarID)

    objCmd.Paramete rs.Append _
    objCmd.CreatePa rameter("Proper tyCode", adVarChar, adParamInput, 20, PropertyCode)

    'Execute the Command object
    objCmd.Execute
Working...