Forum Discussion

steve_hall's avatar
steve_hall
Contributor
12 years ago

DB Table Project Variables - change source in code

Hi All,



I have a Project Variable of type "DB Table". Actually, I have 2 of them!



Iteratively processing the first, produces a return value which is a file path - and I need to use this file path as the source for my 2nd Project Variable.



I've tried all sorts along the lines of 



Project.Variables.ObjDefFile = ObjDataPath;



But everything I've tried results in a JScript error and the script terminating.



Incidentally, "ObjDataPath" is a path to a CSV file... I could probably arrange for this to be xls / xlsx, but if we could work with a CSV as a DB Table (or similar), that'd be good!





Any suggestions?



Thanks!

6 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Steve,


     


    We have a corresponding suggestion in our DB - I've increased its rating based on your request.


    Currently, I cannot give you more precise time estimates regarding the terms of the functionality's implementation.


     

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Steve,


     


    As far as I understand, the ObjDefFile variable has the DBTable type, right? In this case, it's incorrect to assign the path to a csv file to this variable. To access the column data, you need to use the Value(...) property of the DBTableVariable object. 


    I suppose that using the DDT feature will be more convenient in your case - there is no need to create a variable that will contain a table with data. Refer to the "Data-Driven Testing" article for more information.


     

  • Hi Tanya,



    So I have 2 project level variables, both of type DBTable....



    In Project properties, I can see that "TestDriver" has a default value of "{Worksheet: "AmritTest1"; workbook: "..\..\AmritTest1.xlsx"}"



    While "ObjDefFile" has a default value of "{no table}". This is because I want to point ObjDefFile to a number of different files (could be XLS, or CSV, not yet made my mind up, but will always be the same filetype!) - and the path to this file will come from a value extracted as part of processing "TestDriver". So one of the columns in TestDriver might contain:



    c:\file1.xls

    c:\file2.xls

    c:\file3.xls



    As the script reads these different values, I need "ObjDefFile" to use the contents of these files for subsequent processing in the script. ie, ObjDefFile would need it's "default value" to change programmatically such as:



    "{Worksheet: "localdata"; workbook: "c:\file1.xls"}"

    "{Worksheet: "localdata"; workbook: "c:\file2.xls"}"

    "{Worksheet: "localdata"; workbook: "c:\file3.xls"}"



    Is this possible?



  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Steve,


     


    Filling in DBTable variables is possible only from the Project Editor. If you want to use data from Excel or CSV files from the script, use the DDT feature.


     

  • I figured that might be the case!



    Many thanks Tanya.



    Going forward, a possible enhancement in a future release?!



    Cheers



    Steve



  • chaitu430's avatar
    chaitu430
    Occasional Contributor

    Hi, Could you please provide an update if this would be available in the near future ? Thank you. 

     

    - Krish