LoadRunner connect to SQL database, get CAPTCHA script

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.