This is a migrated thread and some comments may be shown as answers.

Get data from data source to validate againt record in SQL database.

1 Answer 22 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pavan
Top achievements
Rank 1
Pavan asked on 07 Mar 2013, 10:36 PM
SqlCommand thisCommand = thisConnection.CreateCommand();
            
thisCommand.CommandText = "select distinct claimid,claimno,  claimdocumenttypeid from ClaimDocument cd1 inner join Claim c on c.ID = cd1.ClaimID where cd1.RecordStatus = 1 and cd1.claimdocumenttypeid = 1 and c.claimno = Data("Claimno");
I want to compare the current data from the datasource (data binding) to a SQl query in my coded step. How do i refer to the data in the datasource. For eg: I bound SQL Database Table Claim and it has a column name 'Claimno'. when I write a SQL query  to get me a record from a different table ClaimDocument, I want to make sure that Table Claim's claimno is equal to Table claimdetail's claimno. Following is the code I have written, but i get error on execution. Please help


 

 

 

1 Answer, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 12 Mar 2013, 10:20 PM
Hi Pavan,

I apologize for the delay getting back to you on this.

How do i refer to the data in the datasource.

There are a couple of ways. The most direct method is the Data object e.g.

Data["Claimno"];

This will fetch the current value of the column Claimno from the current row from the datasource bound to the test.

You can also get at all of the data for the current row using:

ExecutionContext.CurrentDataRow

This will return the entire DataTable object containing all the data rows that will be used throughout the life of the test:
ExecutionContext.DataSource

Looking at your code I think the only error is you need to use [ ] instead of ( ) characters.

All the best,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Pavan
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or