Loadrunner 串連SQL資料庫,擷取驗證碼指令碼,loadrunnersql

來源:互聯網
上載者:User

Loadrunner 串連SQL資料庫,擷取驗證碼指令碼,loadrunnersql

1、指令碼協議:選擇web service



2、指令碼:

Action()

{
    int NumRows=0;


 
    //建立串連
    lr_db_connect("StepName=DatabaseConnection",
        "ConnectionString=Data Source=192.168.1.251;Initial Catalog=MY_test;Persist Security Info=True;User ID=sa;Password=test1",
        "ConnectionName=MeCon",
        "ConnectionType=SQL",
        LAST );
 
    //執行SQL
    NumRows = lr_db_executeSQLStatement("StepName=PerformQuery",
    "ConnectionName=MeCon",

//   資料庫語句

    "SQLStatement=SELECT TOP 1 SendContent= SUBSTRING(SendContent,CHARINDEX(':',SendContent)+1,6) FROM si_sms ORDER BY id DESC ",

    "DatasetName=MyDataset",
    LAST );
    lr_output_message("The query returned %d rows.", NumRows);


//列印查詢結果
/*
lr_db_dataset_action("StepName=PrintDataset",
"DatasetName=MyDataset",
"Action=PRINT",
LAST );*/


//擷取簡訊內容
    lr_db_getvalue("StepName=GetValue", 
        "DatasetName=MyDataset", 
        "Column=SendContent", 
        "Row=current",
        "OutParam=MyOutputParam", 
        LAST ); 

// 輸出驗證碼
    lr_output_message("The value is: %d", lr_eval_string("{MyOutputParam}") );




    //關閉連結
    lr_db_disconnect("stepname=Disconnect","connectionname=MeCon",LAST);
 
return 0;

}


3、輸出結果:(驗證碼:664545)


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.