cancel
Showing results for 
Search instead for 
Did you mean: 

Reading data from database table

michelle_cox
Occasional Contributor

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 7
giriprasasd100
Occasional Contributor

RE: Reading data from database table

Hi Michelle,



You can use DDT.ADODriver object to connect to a database and access its tables via ADODB.

This object has built-in methods to handle data in tables.



For more information refer TestComplete help topics : "DDT.ADODriver" or

http://www.automatedqa.com/support/viewarticle.aspx?aid=8359&hlite=DDT.ADODriver



Hope it helps you...
michelle_cox
Occasional Contributor

RE: Reading data from database table

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



Thanks

Michelle
YMinaev
Staff

RE: Reading data from database table

Hi Michelle,



You can find examples of connection strings here.

------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
michelle_cox
Occasional Contributor

RE: Reading data from database table

Hi



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
Community Hero

RE: Reading data from database table

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;



var

    lADOObject;

    lADOCommandObject;



begin

    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];    

end;


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
michelle_cox
Occasional Contributor

RE: Reading data from database table

I am using keyword tests not scripts
AlexanderM
Staff

RE: Reading data from database table


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= http://www.automatedqa.com/support/viewarticle/?aid=2538]a keyword test variable[/url], [url= http://www.automatedqa.com/support/viewarticle/?aid=3075]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.
-----

Alexander
Customer Care Manager
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors