Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
executing stored procedure via QTP
#1
Not Solved
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error when executing an UFT automation script alexalloza 0 1,385 10-30-2018, 06:17 PM
Last Post: alexalloza
  Executing via create "RES"xx folder? nishitd 0 1,102 03-07-2018, 01:09 AM
Last Post: nishitd
  QTP-Re-executing script after completion of all iterations JwalantBhatt0602 1 2,544 03-24-2016, 12:37 AM
Last Post: JwalantBhatt0602
  QTP is getting closed after executing first test in MTM(Batch) Shyama 0 2,032 10-07-2014, 07:26 PM
Last Post: Shyama
  QTP11.0 - Date format is changed as text while executing the QTP script. Automation Tester 1 3,904 05-30-2014, 01:25 PM
Last Post: Tarik Sheth

Forum Jump:


Users browsing this thread: 2 Guest(s)