Loadrunner 连接SQL数据库,获取验证码脚本

时间:2015-04-16 10:20:26   收藏:0   阅读:214

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)

技术分享

原文:http://blog.csdn.net/hhabc123456789/article/details/45070817

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!