LoadRunner execute a clause SQL statement

Source: Internet
Author: User

LoadRunner executes the SQL statement action () {int numrows=0; int i=1; Establish database connection Lr_db_connect ("Stepname=databaseconnection", "CONNECTIONSTRING=PROVIDER=SQLOLEDB.1; password=***; Persist Security info=true; User id=sc;initial catalog=egmis_net;data source=192.168.0.3,7777 "," Connectionname=invdatabaseconnection "," Con    Nectiontype=oledb ", last);         Execute the SQL statement numrows=lr_db_executesqlstatement ("Stepname=performquery", "Connectionname=invdatabaseconnection",    "Sqlstatement=select * from T_sale", "Datasetname=mydataset", last);    Lr_output_message ("The query returned%d rows.", NumRows); Print out the results lr_db_dataset_action ("Stepname=printdataset", "Datasetname=mydataset", "Action=print", last);} The code above can run successfully, but what if you want to execute a multi-sentence statement? Continue thinking and want to perform the following declare @OperateID int = 2, @OperateTime date = getdate (), @SaleID intexec p_editsale @Flag = ' new_copy ', @Sale ID = @SaleID output, @CopySaleID = 1680, @IsCopyStyle = 1, @IsCopyShip = 1, @IsCopyBox = 1, @IsCopyScheme = 1, @IsCopyschemecolor = 1, @IsCopySchemeSize = 1, @IsCopyWork = 1, @OperateID = @OperateID, @OperateTime = @OperateTimeexec p_ed Itsale @Flag = ' save_new ', @SaleID = @SaleID, @OperateID = @OperateID, @OperateTime = @OperateTimeexec P_editsale @Flag = ' Clear ', @SaleID = @SaleID, @OperateID = @OperateID, @OperateTime = @OperateTime

LoadRunner connect to SQL database, get CAPTCHA script

1. Script protocol: Select Web Service2, Script: Action () {int numrows=0; Establish 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 sqlnumrows = lr_db_executesqlstatement ("Stepname=performquery", "Connectionname=mecon",//Database statement "SQLStatement= SELECT TOP 1 sendcontent= SUBSTRING (Sendcontent,charindex (': ', sendcontent) +1,6) from si_sms ORDER by ID DESC "," Datasetna  Me=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 execute a clause SQL statement

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.