Testcomplete-study Note 3-script

Source: Internet
Author: User
Tags testcomplete

We can record a script or convert a keyword test to script or write a script directly. The former is much simpler.

For general test, keyword test is enough. but when we need to verify the data changes in database after the user do some operation on UI, we must use script to connect database. keyword test will not meet such requirement.

1. Query:

VaR datauserid;
VaR connstr = "provider = msdasql.1; Password = *****; persist Security info = true; user id = xx; Data Source = xx; initial catalog = xx ";
VaR qry;
Qry = ADO. createadoquery ();
Qry. connectionstring = connstr;
Qry. SQL = "select * From datauser where firstname = 'xx' and lastname = 'xx' and loginusername = 'xx '";

// Call procedure

// Qry. SQL = "Call p_xxxxxxcounts (" + campaignid + ")";
 
// Execute the query
Qry. open ();
Qry. First ();
While (! Qry. EOF)
{
Log. checkpoint ("the checkpoint passed. "+" the user "+ qry. fieldbyname ("firstname "). value + "" + qry. fieldbyname ("lastname "). value + "'Was added successfully in Database ");
Log. Message ("The datauserid is" + qry. fieldbyname ("datauserid"). value );
Datauserid = qry. fieldbyname ("datauserid"). value;
Qry. Next ();
};
// Closes the query
Qry. Close ();
If (null = datauserid)
Log. Error ("the checkpoint failed." + "No such user 'limei Lil' was added in Database ");
Else {...}

2. Execute uid

VaR conn;
Conn = ADO. createadoconnection ();
Conn. connectionstring = connstr;
// Suppress the Login Dialog Box
Conn. loginprompt = false;
Conn. open ();
Conn. Execute _ ("delete from XXX Where datauserid =" + datauserid); // sub table
Conn. Execute _ ("delete from XXXX where datauserid =" + datauserid); // main table
Conn. Close ();

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.