Pages

Wednesday, 19 October 2011

QTP Script: Some code that should help you execute a stored procedure.


' set the parameters of your database here
strDatabaseName = ""
strUser = ""
strPassword = ""
strStoredProcedureName = ""

' create the database object
Set objDB = CreateObject("ADODB.Command")

 

' set the connection string
objDB.ActiveConnection = 
"DRIVER={Microsoft ODBC for Oracle}; " & _
                         "SERVER=" & strDatabaseName & _
                         ";User ID=" & strUser & ";Password=" & strPassword & " ;"

' set the command type to Stored Procedures
objDB.CommandType = 4 
objDB.CommandText = strStoredProcedureName 

' define Parameters for the stored procedure
objDB.Parameters.Refresh

 

' set parameters for stored procedure (i.e. two parameters here)
objDB.Parameters(0).Value = "Param1" 
objDB.Parameters(1).Value = "Param2" 

' execute the stored procedure
objDB.Execute()

 

' destroy the object
Set objDB = Nothing


0 comments:

Post a Comment