Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How can I read data from an Excel Spreadsheet using SilkTest?

How can I read data from an Excel Spreadsheet using SilkTest?

Data can be read from Excel spreadsheets using the SilkTest DB_Tester functions. The following is a sample piece of code that will illustrate. This code uses simple SQL to read from Excel, the user can write specific SQL statements to perform more complex data retrieval.

[-] testcase Database_example ()
[ ] //To tell DBTester what DB to connect to
[ ] STRING sConnectString = "DSN=Test;DBQ=C:\example.xls"
[ ]
[ ] //Connect to database and keep a reference to it
[ ] HANDLE hDB = DB_Connect (sConnectString)
[ ]
[ ] //SQL Command to be carried out on DB
[ ] STRING sSQL = "SELECT * FROM `Sheet1$` `Sheet1$`"
[ ]
[ ] //Execute the SQL Statement and keep a reference to the resulting table
[ ] HANDLE hSQL = DB_ExecuteSQL (hDB, sSQL)
[ ]
[ ] //Variable to hold any data retreived from the database
[ ]
[ ] //Query result table and copy data into variable
[+] while (DB_FetchNext(hSQL, laData))
[ ] //Print one record at a time to a results file
[ ] Print (laData)
[ ]
[ ] //Clean Up and Disconnect
[ ] DB_FinishSQL (hSQL)
[ ] DB_Disconnect (hDB)

Old KB# 21430


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:20
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.