Micro Focus QTP (UFT) Forums
executing stored procedure via QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: executing stored procedure via QTP (/Thread-executing-stored-procedure-via-QTP)



executing stored procedure via QTP - smita godbole - 05-21-2012

Hi,
Can any one tell me how to execute stored procedure? We are using SQL server. In the QTP script I am capturing Session ID from URL and then passing it to Stored procedure but unfortunately after successful db connection I couldn't executed stored procedure the way I wanted.
Following is the code to see what I am doing ...
Code:
s =Browser()Page(":").Link("Please click here to view").GetROProperty("URL")
'msgbox s
StrSession = mid(s,87,23)
Reporter.ReportEvent micDone, "Value check", strObject & " value is equal to " & strSession & "."
Dim Conn, Cmd, oRs
Set Conn = CreateObject("ADODB.Connection")
Conn.CursorLocation = 3
Set Cmd = CreateObject("ADODB.Command")
Conn.Open"Description=for QTP testing;DRIVER=SQL Server;SERVER=xxxx;UID=xxxx;APP=QuickTest Professional;WSID=xxxx;Trusted_Connection=Yes"
Cmd.ActiveConnection = Conn
' Set the command type to Stored Procedures
Cmd.CommandText = xxxx(Name of stored procedure)
Cmd.CommandType = 4
msgbox StrSession
If  StrSession=SessionId Then
Cmd.Parameters("@SessionId").Value =StrSession
Set oRs=Cmd.Execute()

Dim RecordSetCounter, TotalNumberofRecords
TotalNumberofRecords = oRs.RecordCount
msgbox TotalNumberofRecords
msgbox Cmd.Parameters("SessionId").Value
Dim SurveyId,SessionID,MemberID
SurveyId=oRs.fields(0).value
'Reporter.ReportEvent  micDone, "Value check", strObject & " value is equal to " & SurveyId & "."
msgbox SurveyId
SessionID=oRs.fields(1).value
'Reporter.ReportEvent micDone, "Value check", strObject & " value is equal to " & SessionID & "."
msgbox SessionID
MemberID=oRs.fields(2).value
'Reporter.ReportEvent micDone, "Value check", strObject & " value is equal to " & MemberID & "."
msgbox MemberID
End If
Conn.Close
Set Conn=Nothing
Will appreciate your help.
Thanks
Smita