• Home
  • Company
    • About
    • Customers
    • Testimonials
    • Contact Us
    • My Account
  • Products
  • Downloads
  • Tutorials
  • Professional Services
  • Home
  • Company
    • About
    • Customers
    • Testimonials
    • Contact Us
    • My Account
  • Products
  • Downloads
  • Tutorials
  • Professional Services
Free Edition Compatible
How to Access Your Database Using SQL
Objectives
In this tutorial you'll learn HOW TO:
► Connect to your Database from script
► Send SQL SELECT, UPDATE and INSERT queries
► Read query results directly to the Lookup Table (Coronys Dataseet object)
► Show Lookup Table with query results 
All Tutorials
How to ...
Add a New Test Step
Add "Select", "Insert" and "Update" test steps on Test Step Tree.
No parameters are required for these test scripts.
SQL "SELECT" Script
The script performs the following:
► Connect to the Database using the Connection String.
► Create Lookup Table which is a Coronys Datasheet object 
► Transmit the SQL transaction with option to put results into Lookup Table
► Close the Database connection
► Show SQL results in Lookup Table 
► Close Lookup Table object to release resources

Copy the script below and paste it to the template created by the ESL Editor.
Click F1 in ESL Editor for Help and API index.
Adjust the code to you needs and run.
     Declare  Status ,  DB_ID ,  LT
     Declare  ConnString ,  Query
     ; Create Lookup Table object
     LT_Create  LT ,   0 ,   1
     ; Connect to Database
    ConnString = `Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ETS\SamplesEx\ADO_DB\Biblio.mdb`
     DB_Create  DB_ID ,  ConnString
     ; Run SQL transaction and put results to the Lookup Table
    Query  =   `Select TOP 20 * From Authors where Authors.[Year Born]>0;`
     DB_Query  Status ,  DB_ID ,  Query ,  LT
     ; Close connection to the Database
     DB_Delete  DB_ID
     ; Show query results in Lookup Table Datasheet
     LT_UpdateTable  Status ,  LT ,   "Top 20 Records"
     ; Close Lookup Table object 
     LT_Delete  LT
     End
Run the script and it will show query results in Lookup Table sheet.
This ESL Lookup Table object is instrumented with many other useful data manipulation methods like get, update and save data in file.
SQL "INSERT" Script
The script performs the following:
► Connect to the Database using the Connection String.
► Create Lookup Table which is a Coronys Datasheet object 
► Delete entry with index 5 
► Insert new entry with index 5 
► Transmit SELECT and put results into Lookup Table
► Close the Database connection
► Show SQL results in Lookup Table 
► Close Lookup Table object to release resources

Copy the script below and paste it to the template created by the ESL Editor.
Click F1 in ESL Editor for Help and API index.
Adjust the code to you needs and run.
     Declare  Status ,  DB_ID ,  LT
     ; Create Lookup Table object
     LT_Create  LT ,   0 ,   1
     ; Connect to Database
     DB_Create  DB_ID ,   `Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ETS\SamplesEx\ADO_DB\Biblio.mdb`   
     ; Delete record with ID=5
     DB_Execute  Status ,  DB_ID ,   "DELETE FROM Authors WHERE Au_ID=5; "
     ; Insert new record
     DB_Execute  Status ,  DB_ID ,   "INSERT INTO Authors (Author,Au_ID, [Year Born]) VALUES ('Coronys',5,2001); "
     ; Run SQL transaction and put results to the Lookup Table
     DB_Query  Status ,  DB_ID ,   `Select * From Authors where Authors.Au_ID < 20;` ,  LT   
     ; Close connection to the Database
     DB_Delete  DB_ID
     ; Show Lookup Table Datasheet
     LT_UpdateTable  Status ,  LT ,   "Top 20 Records"
     ; Close Lookup Table object 
     LT_Delete  LT    
     End
SQL "UPDATE" Script
The script performs the following:
► Connect to the Database using the Connection String.
► Create Lookup Table which is a Coronys Datasheet object 
► Update an entry with index 5 
► Transmit SELECT and put results into Lookup Table
► Close the Database connection
► Show SQL results in Lookup Table 
► Close Lookup Table object to release resources

Copy the script below and paste it to the template created by the ESL Editor.
Click F1 in ESL Editor for Help and API index.
Adjust the code to you needs and run.
     Declare  Status ,  DB_ID ,  LT
     ; Create Lookup Table object
     LT_Create  LT ,   0 ,   1
     ; Connect to Database
     DB_Create  DB_ID ,   `Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ETS\SamplesEx\ADO_DB\Biblio.mdb`
     ; Run UPDATE transaction
     DB_Execute  Status ,  DB_ID ,   "Update Authors set [Year Born]=2002  where Au_ID = 5"
     ; Run SELECT and put results to the Lookup Table
     DB_Query  Status ,  DB_ID ,   `Select * From Authors where Authors.Au_ID < 20;` ,  LT
     ; Close connection to the Database
     DB_Delete  DB_ID
     ; Show Lookup Table Datasheet
     LT_UpdateTable  Status ,  LT ,   "Top 20 Records"
     ; Close Lookup Table object 
     LT_Delete  LT
     End
  • Home
  • Products
  • Downloads
  • Tutorials
  • Contact Us
  • Terms of Use
  • Privacy Policy

Copyright © 2002-2017 Coronys Ltd. All Rights Reserved.
 
Back to top