update data in a database
To update information is entered into the database at runtime, you will need to add code to your script which will open a connection to the database, update the database, then close the connection. Here are the steps to do this (an example follows). 1. Create an “ADODB.Connection” object (the database object).
2. Set the connection string for the database object.
3. Open the connection to the database.
4. Execute a SQL statement.
5. Close the database connection.
Example:Set cnBiblio = CreateObject(“ADODB.Connection”)
‘ Set the connection string and open the connection
cnBiblio.ConnectionString = “DSN=QT_Flight32;DBQ=C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb;Driver=C:\WINDOWS\System32\odbcjt32.dll;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;”‘ Open the connection to the database
cnBiblio.Open
‘ or use this method if a DSN entry was created.
‘ cnBiblio.Open(“DSN=Flight32”)
‘ Execute the update query (SQL statement)
cnBiblio.Execute “Update Orders SET Orders.Customer_Name = ‘John Doe’ where Orders.Order_Number = 1”
‘ Close the connection.
cnBiblio.Close Note: The syntax of the Update SQL statement may vary depending on the database in use. The example above uses the sample Flight32 MS Access database.
Source: Mercury Forum’s KB articles
-
Archives
- July 2011 (1)
- March 2011 (1)
- November 2010 (1)
- November 2008 (4)
- October 2008 (2)
- September 2008 (2)
- June 2008 (1)
- March 2008 (4)
- February 2008 (44)
-
Categories
- Automated Test Script Creation Process
- Automating MS Word
- Automating QC
- Automation Object Model For QTP
- Backward compatability in QTP
- Browser Scripts
- COM and QTP
- compare 2 text files
- Descriptive programming
- Descriptive Programming and Child Objetcs
- Dictonary Object
- DotNetFactory
- Excel Automation
- Extra Topics
- Files and Folders
- General Standards to be followed in Test scripts
- New Features In QTP9.5
- QC-OTA
- QTP Additional Faqs
- QTP Faqs
- QTP Naming Convention
- QTP Tips and Faqs
- Running stored procedures from QTP
- Send keyboard keys
- Uncategorized
- Uninstall a software using QTP
- Uninstall a software using vbscript
- Update data in a database
- VBScript and IE Automation
- VBScript Faqs and Useful resources
- What’s New in Quick Test Pro 9.0
- Whats New in QTP 9.5
- XML Scripting
-
RSS
Entries RSS
Comments RSS