Loadrunner orcale11g

#include "lrd.h"   //头文件
#include "web_api.h"
#include "lrw_custom_body.h"
Action()
{
int i;
//连接数据库
lr_db_connect("StepName=Connect", 
  "ConnectionString=Provider=OraOLEDB.Oracle.1; Data Source=****; Persist Security Info=True; User ID=****;Password=****", 
  "ConnectionName=db1",
  "ConnectionType=OLEDB",
  LAST);
lr_start_transaction("SQL");
NumRows = lr_db_executeSQLStatement("StepName=PerformQuery",
    "ConnectionName=db1",
    "SQLStatement=select * from p_order",//设置执行数据库脚本
    "DatasetName=MyDataset",
    LAST );
    lr_end_transaction("SQL", LR_AUTO);//获得查询记录所开销的时间
    lr_output_message("The query returned %d rows.", NumRows);

//循环读取并输出sql查询得到的值,这里的判断根据需要适当进行修改
    while(i<NumRows) {
lr_db_getvalue("StepName=GetValue",
        "DatasetName=MyDataset",
        "Column=order_id",  //Column 为要取得列的值,
        "Row=next";
        "OutParam=MyOutputParam",
        LAST);
lr_output_message("The value is: %s", lr_eval_string("{MyOutputParam}") );
i=i+1;
}

lr_db_disconnect("StepName=Disconnect",
            "ConnectionName=db1",
            LAST);
return 0;
}

问题1:Action.c(17): Error: C interpreter run time error: Action.c (17):  Error -- Unresolved symbol : lr_db_connect.

解决方法:采用协议错误,换成websevice协议后解决。

 问题2:Error: Getting db failed {"未将对象引用设置到对象的实例。"}    

while(i<NumRows) {
lr_db_getvalue("StepName=GetValue",

"DatasetName=MyDataset", "Column=order_id",  //Column 为要取得列的值"Row=next",

OutParam=MyOutputParam",
LAST);

解决方法: Column取值不存在

你可能感兴趣的:(Loadrunner orcale11g)