save param 参数无效。错误代码: 9005。
本帖最后由 MYMREMIND 于 2010-10-27 08:52 编辑大家好,我在用socket协议写了个脚本后,回放没有错误,执行场景的时候,如果不加持续时间也没有错误,但是一加入持续时间,执行场景的时候就会报错:save param 参数无效。错误代码: 9005
求解决,谢谢!
详细脚本:
Init:
#include "lrs.h"
vuser_init()
{
char m;
char n;
char a;
lr_load_dll("msado15.dll");
lr_load_dll("SQLConnector.dll");//调用数据库操作DLL
memcpy(m, lr_eval_string("<NewParam>"),strlen(lr_eval_string("<NewParam>")));
memcpy(n, lr_eval_string("<NewParam_1>"),strlen(lr_eval_string("<NewParam_1>")));
strcat(m,n);
memcpy(a, lr_eval_string("<NewParam_2>"),strlen(lr_eval_string("<NewParam_2>")));
strcat(m,a);
//从两个数据库中分别提取数据然后组合成一个字符串
lr_save_string(m,"inputstr");//将m的值保存到参数inputstr
lr_output_message("inputstr=%s",lr_eval_string("<inputstr>"));
lrs_startup(257);
return 0;
}
Action:
include "lrs.h"
Action()
{
char cmd_str;
char outputmsg;
struct {
char f1c;
intf1i;
longf1l;
char f2c;
intf2i;
long f2l;
char f3c;
intf3i;
long f3l;
}insertfiled;
lrs_save_param_ex("socket0","user",lr_eval_string("<inputstr>"), 0, strlen(lr_eval_string("<inputstr>")),NULL, "NewParam1");
//将要发送到server端的数据从init部分传递过来并保存到参数NewParam1
lrs_create_socket("socket0","TCP","RemoteHost=10.120.33.5:3343",LrsLastArg);
lr_rendezvous("sendmessage");
lr_start_transaction("sendmessage");
lrs_send("socket0","buf0",LrsLastArg);//发送
lrs_receive("socket0","buf1",LrsLastArg);//接收
lr_end_transaction("sendmessage", LR_AUTO);
//接收服务器返回消息
lrs_save_param("socket0",NULL,"Param_Return",0,2);
lr_output_message("Param_Return=%s",lr_eval_string("<Param_Return>"));
//读取buf1中接收到的数据
lrs_save_param("socket0","buf1","Param_Buffer",0,30);
lr_output_message("Param_Buffer=%s",lr_eval_string("<Param_Buffer>"));
memset(outputmsg,0,sizeof(outputmsg));
memcpy(outputmsg,lr_eval_string("<Param_Return>"),strlen(lr_eval_string("<Param_Return>")));
memset(cmd_str,0,sizeof(cmd_str));
strcpy(cmd_str,"insert into test3 values(");//将服务器端返回的数据插入到数据库
sprintf(insertfiled.f1c,"%s",lr_eval_string("<Param_Buffer>"));
sprintf(insertfiled.f2c,"%s","Getdate()");
sprintf(insertfiled.f3c,"%s",lr_eval_string("<Param_Return>"));
strcat(cmd_str,"'");
strcat(cmd_str,insertfiled.f1c);
strcat(cmd_str,"',");
strcat(cmd_str,insertfiled.f2c);
strcat(cmd_str,",'");
strcat(cmd_str,insertfiled.f3c);
strcat(cmd_str,"')");
Insert(cmd_str);
if(strncmp(insertfiled.f3c,"00",2)!=0) //如果返回码不等于00,输出错误提示
{lr_error_message(outputmsg);}
lr_think_time(1);
return 0;
}
End:
include "lrs.h"
vuser_end()
{
lrs_cleanup();
return 0;
}
Date.WS
;WSRData 2 1
send buf0 30
"<NewParam1>"
recv buf1 30
-1 报错地方:
lrs_save_param("socket0",NULL,"Param_Return",0,2);
lr_output_message("Param_Return=%s",lr_eval_string("<Param_Return>")); 没有人? 估计要详细的脚本才能看出来了 详细脚本已附上,请高手解决 {:4_91:} 没有人呐, 求高手解决 {:4_91:} 没有人给点意见么,{:4_102:} :sleepy: 好多自己写的代码,都不懂哎。支持一下 回复 12# sincool
呵呵,郁闷了,场景一加上持续时间就报这个错误,但是数据依然插入到数据库中了,很是困惑.. lrs_save_param("socket0",NULL,"Param_Return",0,2);
你把这句改成这样试试
lrs_save_param("socket0",LRS_LAST_RECEIVED,"Param_Return",0,2); sockets。。。。看不懂。。。 {:4_83:} 问题已解决,一个很低级的错误,我忘了写这句:lrs_close_socket("socket0");:funk:
惭愧~
页:
[1]