Importing Data from a Database - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming) +--- Thread: Importing Data from a Database (/Thread-Importing-Data-from-a-Database) |
Importing Data from a Database - rajeshwar - 05-26-2010 Hi Guys, Is there any way to Automate the feature provided by QTP to import data from a Database Table to DataSheet(Sheet>>Import>>From Database) where we can establish the connection and fetch the Data from a database table. Can we acheive this using QTP object Model? I have the information that data can be fetched from DB in following manner, just wondering if there's a Way to acheive Import Database feature of QTP DataSheet. ---------------------------------------------------------- Code: set con = CreateObject("adodb.connection") RE: Importing Data from a Database - Saket - 05-26-2010 Yes, you are in the right direction. this will import the data set to QTP Data table RE: Importing Data from a Database - rajeshwar - 05-26-2010 Hi Saket, We are looking for a better approach than this, where we can just specify the table name and the entire table content gets imported to datatable along with column headers at runtime? Like we do Importsheet with excel. Is this possible using QTP object model? If yes can somebody give an example. Thanks, Raj. RE: Importing Data from a Database - venkatbatchu - 07-14-2010 Hi, You can use the below code to work like Datatable.Import i.e which will add all the field names (available in data base) to excel i.e outsheet Code: set outsheet=Datatable.Addsheet("output") Please let me know if you need any clarification Regards, Venkat.Batchu RE: Importing Data from a Database - venkatbatchu - 08-27-2010 Hi Rajeshwar, Please find the below code which i have done on flight application. The following code fetch the data from database to data table. Code: Dim adocon,adorecordset Please let me know for further clarification. Regards, Venkat. Batchu RE: Importing Data from a Database - lotos - 09-14-2010 hi rajeshwar, try this method: Code: Public Function DBQuery And call it within your steps/actions as here: Code: ' get the Requested value from DB sqlSelect = UCASE("SELECT CLB5VA as ValueFromDB FROM CSCLREP WHERE CLAINB = '80808' AND CLBHDT = '1100909' and CLWTNB='01'") itemCode = "ValueFromDB" or itemCode = "CLB5VA". The 'IF' statements are used if you are testing on more than one environments. Remove IF if it is not necessary for your project. On my project this code is working very good. RE: Importing Data from a Database - lotos - 11-23-2010 hi man, you can look here: DB selects from QTP... also for updates, if you need: DB Updates from QTP... Hope this will help you! RE: Importing Data from a Database - Seema Gupta - 04-12-2011 I have not actually tried /work on it but what you can do is 1) Export Functionality of SQL to export the given data in table to excel sheet. 2)Once your xls file is ready, you can import it to QTP with DataTable.Import "filepath" As compared to your solution this will take less time. Regards, Seema Gupta RE: Importing Data from a Database - qtp-qa - 04-03-2012 Hi, I have created a qtp test for an application. Which is: Code: Option Explicit This is running fine in Qtp but I want to run the script without Qtp. So I pasted the script in notepad and saved it as .vbs file. But when I close Qtp to run the .vbs file it gives me error saying "Variable is undefined : "window"" error code 800A01F4 (Line 6, Char 1) Can anybody please explain me why am I getting this error? |