First you need to install LR. NET add-in, write code in the development environment, do a database connection, and then invoke the Execute stored procedure.
After installing, open the program, you should see the menu bar more than one:
Then add an LR project:
Then you can encode it, I wrote a code, as follows:
Using System;
Using System.Runtime.InteropServices;
Using System.ComponentModel;
Using System.Data;
Using System.Data.OracleClient;
Using Shangxin.data;
Using System.Collections;
Using System.Web;
Namespace Loadrunneruser
{
<summary>
Summary description for Vuserclass.
</summary>
[ClassInterface (Classinterfacetype.autodual)]
public class Vuserclass
{
Loadrunner.lrapi LR;
protected System.Data.OracleClient.OracleDataAdapter Oracleda;
protected System.Data.OracleClient.OracleCommand Loadcommand;
protected System.Data.OracleClient.OracleConnection OracleConnection;
Public Vuserclass ()
{
LoadRunner Standard API Interface:: Does not REMOVE!!!
LR = new Loadrunner.lrapi ();
}
Protected System.Data.OracleClient.OracleConnection getoracleconnection ()////sqlconnection
{
if (oracleconnection==null)
Oracleconnection=new System.Data.OracleClient.OracleConnection ();
oracleconnection.connectionstring= "User id=test; Password=write;data Source=escalade ";
return oracleconnection;
}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Initialize ()
{
To Do:add virtual user ' s initialization routines
return LR. Pass;
}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Actions ()
{
Try
{
Lr.start_transaction ("Testgetwithdraworderbycode");
System.Data.OracleClient.OracleConnection conn = new OracleConnection ("User id=test; Password=write;data Source=escalade ");
System.Data.OracleClient.OracleCommand comm = new OracleCommand ();
Comm. Connection = conn;
Comm.commandtext = "BILL." Getwithdraworderbycode ";
Comm.commandtype = CommandType.StoredProcedure;
Input parameters
System.Data.OracleClient.OracleParameter Param1=comm. Parameters.Add ("V_code", oracletype.varchar,20);
param1. Direction = ParameterDirection.Input;
param1. Value = "TH15";
Output parameters
System.Data.OracleClient.OracleParameter Param2=comm. Parameters.Add ("Retcursor", oracletype.cursor);
Param2. Direction = ParameterDirection.Output;
DataTable dt = new DataTable ();
Oracleda = new System.Data.OracleClient.OracleDataAdapter ();
Oracleda.selectcommand = comm;
Oracleda.fill (DT);
int Icount=convert.toint32 (dt. Rows.Count.ToString ());
if (icount>0)
Lr.end_transaction ("Testgetwithdraworderbycode", LR. PASS);
Else
Lr.end_transaction ("Testgetwithdraworderbycode", LR. FAIL);
}
catch (Exception ex)
{
String error = Ex. message;
}
return LR. Pass;
}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Terminate ()
{
To Do:add virtual user ' s termination routines
return LR. Pass;
}
}
}
Remember to add the necessary references, use the flexibility to grasp the specific