Krishna_Kumar
6 years agoContributor
DBTable
Hi team,
Can we read Excel data using adodb string (recordset) and update the same in project's DBTable in a single statement.
If that is possible can anyone guide me with the solution. Or esle w...
Question:
Why would you need to read the excel sheet into a DBTable variable? TestComplete can work with the excel sheet directly in a variety of ways.
The short answer to your question is.... not in a single code statement, no. However, the DBTable variable can be configured to point to a variety of data sources. Have you tried selecting Excel directly when setting up your DBTable?
Like tristaanogre said, you might want to think about why you are trying to do this as you have access to the data already in the Excel sheet from TestComplete
If we are mising something, then the answer is YES, you can do that, if you need to anyway.
Use the ADO object to create a connection, passing the connection string to your Excel OleDB Provider, then execute the query on the ADO object with the connection to get a dataset back from the excel sheet.
From that you can iterate through the dataset to find out how many rows and columns you have.
With a double for loop to go columns wide and rows high, you can create the DBTable programtically and assign the value for each cell during the iteration of the 2 for loops.
Hope that helps
-Lino