Forum Discussion

Krishna_Kumar's avatar
Krishna_Kumar
Contributor
5 years ago

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 why can't team add this as a feature in the upcoming update ?

 

Kind regards,

Sathish Kumar k

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    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?

    • LinoTadros's avatar
      LinoTadros
      Community Hero

      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