在Loadrunner中也提供了C对数据库操作的相关功能函数,以下这些数据库功能函数只能用于Web Services协议。 lr_db_connect 连接数据库 lr_db_disconnect 断开数据库的连接 lr_db_executeSQLStatement 执行SQL语句 lr_db_dataset_action 对数据库执行操作 lr_db_getValue 从数据集中检索值 lr_db_connect函数默认支持四种数据库连接模式: ·SQL(原生MS SQL Server) ·OLEDB(使用OLEDB连接数据库) ·ODBC ·ORACLE 1、新建Web Service协议脚本; 2、编写测试脚本,如下: Action() { int NumRows=0; int i; //连接数据库 lr_db_connect("StepName=testConnect", "ConnectionString=Provider=OraOLEDB.Oracle.1,Data Souce=ORCL;" "Persist Security Info =True;" "User ID=scott;" "Password=tiger", "ConnectionName=db_orcl", "ConnectionType=OLEDB", LAST); lr_start_transaction("query_1"); //查询sql:select * from lr_auto_users NumRows=lr_db_executeSQLStatement("StepName=query_1", "ConnectionName=db_orcl", "SQLStatement=select * from lr_auto_users", "DatasetName=LrAutoUsers_Dataset", LAST); lr_end_transaction("query_1",LR_AUTO); lr_output_message("总共%d条数据:",NumRows); while(i
posted on 2015-03-17 10:25  学习测试的豆豆~  阅读(1395)  评论(1编辑  收藏  举报