05-21-2012, 10:21 PM
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 ...
Will appreciate your help.
Thanks
Smita
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
Thanks
Smita