Forum Discussion

michelle_cox's avatar
Occasional Contributor
15 years ago

Reading data from database table

I have been able to record keyword tests were data from excel is read and used as input data in my test using the Excel DDT driver (as per the sample video). Is there a similar way to do the same but read data from a database table rather than a spreadsheet?

7 Replies

  • michelle_cox's avatar
    Occasional Contributor
    I have had a look at that link but it doesn't really describe how you go about using the ADODriver i.e do I use a code expression for the connection string or is it a constant etc?? And what is the syntax do I use for the connection string?

    I have attached the screen shot - what are the parameters I need to enter


  • michelle_cox's avatar
    Occasional Contributor

    This does not help me enough. I am very new to this application so basically what I want to know (in a simple step by step way) is how to look up the data in a table in my orcale schema and use that data as a value in my test.

    So for example I am testing orders.exe application and I want to take a value from a column my 'address' table and use that to populate the orders form in the the orders.exe application.

    How do I go about doiung this?

  • tristaanogre's avatar
    Esteemed Contributor
    Hi, Michelle,

    Try something like this.  This is untested, uses DelphiScript, and uses MSSQL but the concepts should be the same and should show how to build something like this.

    function GetTableValue;





        lADOObject := DDT.ADODriver;

        lADOConnectObject := DDT.ADODriver.ADOConnectionObject;

        lADOObject.ADOConnectionObject.ConnectionString := Provider = 'SQLOLEDB; User ID = sa; Password = testing; Initial Catalog = QASCRIPTS30; Data Source = qatest02\SQLExpress; LoginPrompt := False;';

        lADOObject.ADOCommandObject.CommandText := 'SELECT Name from Customers where CustomerID = 1';

        Result := lADOObject.Value[0];    


  • Hi Michelle,

    Currently, it is not possible to accomplish your task without any scripting.

    As you are using keyword tests, you can execute the function suggested by Robert by using the Run Script Routine operation. Please note that the value returned by the script function needs to be stored in [url=]a keyword test variable[/url], [url=]a project variable, or a project suite variable[/url]. For example, you can change the following code line of Robert's code:

        Result := lADOObject.Value[0];

    like this

       // Please note that you need to create the Var1 variable before executing the routine.

        Project.Variables.Var1 := lADOObject.Value[0];

    Then, you will be able to work with the value stored in this variable in the way you want.