How to save data in application based on xls records ?
How to save data in application based on xls records ?
Hi Support,
I am working on a solution in which a button click depends on the values present in the next row of excel sheet, suppose I need to save a group of data which is fetched from a excel file only if record in the next line does not correspond to the current dataset. Is there any way to check if the next record is related to the current record ?
Example: As per attached excel,
The column A and B are parent data cells, C to E are child data cells.
I am creating a parent record which will have child data records. Let say I create a parent record with A,B as name and description and then I add child records to this which are present in cells C2,D2,E2 in excel.
Now next line is also of the same parent record with different child, for which data is present in C3,D3,E3. Then I finally enter the third record under the same parent record. Now if it is seen the next record is not corresponding to the current one, so I will save the master record after I have entered all the three records.
Is there any way to check what is present in the next row of data in Excel before saving the parent dataset?
Thanks & Regards,
Varun.
I am working on a solution in which a button click depends on the values present in the next row of excel sheet, suppose I need to save a group of data which is fetched from a excel file only if record in the next line does not correspond to the current dataset. Is there any way to check if the next record is related to the current record ?
Example: As per attached excel,
The column A and B are parent data cells, C to E are child data cells.
I am creating a parent record which will have child data records. Let say I create a parent record with A,B as name and description and then I add child records to this which are present in cells C2,D2,E2 in excel.
Now next line is also of the same parent record with different child, for which data is present in C3,D3,E3. Then I finally enter the third record under the same parent record. Now if it is seen the next record is not corresponding to the current one, so I will save the master record after I have entered all the three records.
Is there any way to check what is present in the next row of data in Excel before saving the parent dataset?
Thanks & Regards,
Varun.
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to save data in application based on xls records ?
Hello Varun,
You can try the following code snippet to compare the values of the current row and the next row in your data source.
Bernhard
Ranorex Support Team
You can try the following code snippet to compare the values of the current row and the next row in your data source.
var dataConn = DataSources.Get("YourConnector"); int rowIndex = TestCase.Current.DataContext.CurrentRowIndex; if(dataConn.Rows[rowIndex-1].Values[0].ToString() != dataConn.Rows[rowIndex].Values[0].ToString()) { Report.Info("Save Record!"); }Regards,
Bernhard
Ranorex Support Team
Re: How to save data in application based on xls records ?
Hello Bernhard,
Thanks for your feedback.
We have changed our data source format after some internal discussions, PFA the latest data source format and suggest accordingly for the same problem.
Thanks for code snippet.
Regards,
Varun.
Thanks for your feedback.
We have changed our data source format after some internal discussions, PFA the latest data source format and suggest accordingly for the same problem.
Thanks for code snippet.
Regards,
Varun.
You do not have the required permissions to view the files attached to this post.
Re: How to save data in application based on xls records ?
Hi Support,
Can I have your suggestions on this
Please let me know if need more clarification.
Thanks & Regards,
Varun.
Can I have your suggestions on this
Please let me know if need more clarification.
Thanks & Regards,
Varun.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to save data in application based on xls records ?
Hello Varun,
You can use a global parameter to save the current value of the row and check if the value of the next row is equal to the value of the global parameter.
Bernhard
Ranorex Support Team
You can use a global parameter to save the current value of the row and check if the value of the next row is equal to the value of the global parameter.
if(dataConn.Rows[rowIndex-1].Values[0].ToString() != "") { TestSuite.Current.Parameters["YourGlobalParameter"] = dataConn.Rows[rowIndex-].Values[0].ToString(); } if(TestSuite.Current.Parameters["YourGlobalParameter"] != dataConn.Rows[rowIndex].Values[0].ToString() && dataConn.Rows[rowIndex].Values[0].ToString() != "") { Report.Info("Save Record!"); }Regards,
Bernhard
Ranorex Support Team
Re: How to save data in application based on xls records ?
Hello Bernhard,
Thanks for your kind support.
I tried to apply the provided code snippet but its not working. Stuck against one error, seems we need to change our logic.
Please see attached "Script1017.cs" to get the logic I am working on and "Error1.png" for the error and the steps to execute this case.
Please go through the earlier replies of this posts to get your hands wet for scenario. Response awaited!!
Thanks & regards,
Varun.
Thanks for your kind support.
I tried to apply the provided code snippet but its not working. Stuck against one error, seems we need to change our logic.
Please see attached "Script1017.cs" to get the logic I am working on and "Error1.png" for the error and the steps to execute this case.
Please go through the earlier replies of this posts to get your hands wet for scenario. Response awaited!!
Thanks & regards,
Varun.
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to save data in application based on xls records ?
Hi,
Regards,
Tobias
Ranorex Team
as the error message says, implicit typed variables cannot be used as class members, they can only be used as local variables inside methods.varun wrote: Please see attached "Script1017.cs" to get the logic I am working on and "Error1.png" for the error and the steps to execute this case.
Regards,
Tobias
Ranorex Team
Re: How to save data in application based on xls records ?
Hi Support,
I have made a change (see ChangesMade_1018.png), after which stuck against bulk amount of errors(see Errors_1018.png). Try to handle these errors by every way but no results.
So please look into .cs file provided in previous post and snapshots of this post, and guide me for the exact solution on this.
Response awaited!!
Thanks & Regards,
Varun.
I have made a change (see ChangesMade_1018.png), after which stuck against bulk amount of errors(see Errors_1018.png). Try to handle these errors by every way but no results.
So please look into .cs file provided in previous post and snapshots of this post, and guide me for the exact solution on this.
Response awaited!!
Thanks & Regards,
Varun.
You do not have the required permissions to view the files attached to this post.
Re: How to save data in application based on xls records ?
Hi RX Support,
Please guide me on this in detail. Your response awaited.
Let me know if more description required on this problem.
Regards,
Varun.
Please guide me on this in detail. Your response awaited.
Let me know if more description required on this problem.
Regards,
Varun.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to save data in application based on xls records ?
Hi,
You are getting the errors because the variable names does not exist in the current context.
This is because C# is case sensitive and "rowindex" is not the same as "rowIndex", I suppose this is the reason for all your errors.
Regards,
Markus
Ranorex Support Team
You are getting the errors because the variable names does not exist in the current context.
This is because C# is case sensitive and "rowindex" is not the same as "rowIndex", I suppose this is the reason for all your errors.
Regards,
Markus
Ranorex Support Team
Re: How to save data in application based on xls records ?
Hi Markus,
I made changes as per your suggestion, this reduce the count of errors but not fully resolve the problem.
So please tell what will the fix of other errors ?? See "Errors_1018.png" snapshot attached with previous reply for list of all errors.
Response awaited.
Thanks & Regards,
Varun.
I made changes as per your suggestion, this reduce the count of errors but not fully resolve the problem.
So please tell what will the fix of other errors ?? See "Errors_1018.png" snapshot attached with previous reply for list of all errors.
Response awaited.
Thanks & Regards,
Varun.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to save data in application based on xls records ?
Hi Varun,
Then please post us a screenshot of the still existing errors and the code which throws it.
Regards,
Markus
Ranorex Support Team
Then please post us a screenshot of the still existing errors and the code which throws it.
Regards,
Markus
Ranorex Support Team
Re: How to save data in application based on xls records ?
Hi Markus,
As required, PFA Code and Error snapshot. And kindly tell me what needs to be done to get the clean build.
Thanks & Regards,
Varun.
As required, PFA Code and Error snapshot. And kindly tell me what needs to be done to get the clean build.
Thanks & Regards,
Varun.
You do not have the required permissions to view the files attached to this post.
Re: How to save data in application based on xls records ?
Hi Markus,
Your response awaited, please provide me with solution for the Issues attached in my last post.
Regards,
Varun.
Your response awaited, please provide me with solution for the Issues attached in my last post.
Regards,
Varun.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to save data in application based on xls records ?
Hi Varun,
The error messages show why you are getting the errors, and the code which throws them is also marked (red underlined). The variable "dataConn" is still wrong because you named the variable "dataconn", I suppose it is the same for Variable "Add_EqGrpEq" and as the error message also stated the first argument of the IDictionary (TestSuite.Current.Parameters[]) must be a "string" and not an "int".
I hope this will help you to solve the issue!
Regards,
Markus
Ranorex Support Team
The error messages show why you are getting the errors, and the code which throws them is also marked (red underlined). The variable "dataConn" is still wrong because you named the variable "dataconn", I suppose it is the same for Variable "Add_EqGrpEq" and as the error message also stated the first argument of the IDictionary (TestSuite.Current.Parameters[]) must be a "string" and not an "int".
I hope this will help you to solve the issue!
Regards,
Markus
Ranorex Support Team