1. Script protocol: Select Web Service
2. Script:
Action ()
{
int numrows=0;
Establish a connection
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);
Execute SQL
NumRows = Lr_db_executesqlstatement ("Stepname=performquery",
"Connectionname=mecon",
Database statements
"Sqlstatement=select TOP 1 sendcontent= SUBSTRING (Sendcontent,charindex (': ', sendcontent) +1,6) from the si_sms ORDER by ID DESC ",
"Datasetname=mydataset",
last);
Lr_output_message ("The query returned%d rows.", NumRows);
Print Query Results
/*
Lr_db_dataset_action ("Stepname=printdataset",
"Datasetname=mydataset",
"Action=print",
last); * *
Get SMS Content
Lr_db_getvalue ("Stepname=getvalue",
"Datasetname=mydataset",
"Column=sendcontent",
"Row=current",
"Outparam=myoutputparam",
last);
Output Verification Code
Lr_output_message ("The value is:%d", lr_eval_string ("{Myoutputparam}"));
Close link
Lr_db_disconnect ("Stepname=disconnect", "Connectionname=mecon", last);
return 0;
}
3. Output result : (Code: 664545)
LoadRunner connect to SQL database, get CAPTCHA script