Hi,
I'm pretty new at Ranorex, and not able to code yet.
I made an Access database with some variables of an address in it, and bound them to my testcase. That works fine! But what I want now is that if the test case succeeds, the housenumber in the Access database is increased with 1.
We start for example with Testingstreet 1, next time that should be Testingstreet 2.
Is it possible to include this in my recording? I see I can use GetValue to pick up the latest used number, but how do I pass this value+1 to my Access table?
Update data connector
Re: Update data connector
Hi,
I'm afraid I'm not exactly sure what you want to achieve. Did I understand you correctly that you want to update the data source (in your case, the database table) during test execution or do you need this incremented value only for the current iteration of the test (for example, to enter this value in any input field)?
Could you upload a screenshot of the current content of the data source? Probably, it would be helpful to try illustrating the issue with a sample solution.
I'm afraid I'm not exactly sure what you want to achieve. Did I understand you correctly that you want to update the data source (in your case, the database table) during test execution or do you need this incremented value only for the current iteration of the test (for example, to enter this value in any input field)?
Could you upload a screenshot of the current content of the data source? Probably, it would be helpful to try illustrating the issue with a sample solution.
Re: Update data connector
I want to write TO the Access database.
I created a new house address: Testingstreet 1, 0000AA TestCity.
Next time, I want to use house number 2, because it is forbidden to create an address that already exists.
So I want to GetValue from the created address (value = 1), and write this +1 to the Access table.
I created a new house address: Testingstreet 1, 0000AA TestCity.
Next time, I want to use house number 2, because it is forbidden to create an address that already exists.
So I want to GetValue from the created address (value = 1), and write this +1 to the Access table.
You do not have the required permissions to view the files attached to this post.
Re: Update data connector
Ranorex doesn't provide any API functionality to update database information, but Ranorex is basically based on the .NET framework, which means that you could implement this functionality with C# code.
I would suggest having a look at the following instruction and the corresponding stackoverflow discussion.
In Ranorex this could be, for example, implemented as a user code action.
Hope this helps!
I would suggest having a look at the following instruction and the corresponding stackoverflow discussion.
In Ranorex this could be, for example, implemented as a user code action.
Hope this helps!
Re: Update data connector
I'm sorry, but not really... I keep getting "The user code class has compile errors".
Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
namespace K2W_Desktop._Algemeen
using System.Data.OleDb
{
public partial class Test
{
private void Init()
{
// Your recording specific initialization code goes here.
}
public void Huisnummer_plus_1()
{
try
{
OleDbConnection con = new OleDbConnection("M:\\hhs\\Werkruimtes\\Testteam\\Ranorex\\Variabelen\\Variabelen.accdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("update [Variabelen] set varHuisnummer = varHuisnummer +1 where id=1", con);
cmd.ExecuteNonQuery();
lbl_msg.Text = "Record Updated Successfully.";
con.Close();
}
catch
{
lbl_msg.Text ="Error Occured.";
}
}
}
}
Re: Update data connector
Hi,
Change this part of code:
To this:
Change this part of code:
Code: Select all
namespace K2W_Desktop._Algemeen
using System.Data.OleDb
{
Code: Select all
using System.Data.OleDb;
namespace K2W_Desktop._Algemeen
{
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Update data connector
Your code has definite formatting issues, just from looking at it.
If you have never coded (especially in C#.NET) before, I would highly recommend some training or reading before you try to do what you are wanting to do. What you want to do is a non-trivial task and not knowing how to code will only complicate it. There is only so much we can help with, and if you don't understand the code, or the changes we recommend, it will be that much harder.
For example:
The "using" directives must ALL be above the "namespace" declaration.
All lines of code must end with a semicolon (";") or, for blocks, a block closing bracket ("}"). All blocks must have an opening bracket ("{") and closing bracket.
Your code has a using statement in between the namespace declaration and the namespace's block. That using statement also doesn't have a semicolon ending the line.
In addition, this code is a partial class. Since you don't give us the full class declaration, it is hard to know what you are dealing with. Is this a partial class that is part of a recording module?
Should be:
If you have never coded (especially in C#.NET) before, I would highly recommend some training or reading before you try to do what you are wanting to do. What you want to do is a non-trivial task and not knowing how to code will only complicate it. There is only so much we can help with, and if you don't understand the code, or the changes we recommend, it will be that much harder.
For example:
The "using" directives must ALL be above the "namespace" declaration.
All lines of code must end with a semicolon (";") or, for blocks, a block closing bracket ("}"). All blocks must have an opening bracket ("{") and closing bracket.
Your code has a using statement in between the namespace declaration and the namespace's block. That using statement also doesn't have a semicolon ending the line.
In addition, this code is a partial class. Since you don't give us the full class declaration, it is hard to know what you are dealing with. Is this a partial class that is part of a recording module?
Code: Select all
namespace K2W_Desktop._Algemeen
using System.Data.OleDb
{
Code: Select all
using System.Data.OleDb;
namespace K2W_Desktop._Algemeen
{
Shortcuts usually aren't...
Re: Update data connector
The instruction link I got from jma says: Use below namespace. using System.Data.OleDb;
I found that strange, but tried it. Also the other way around... still a compiling error.
And that was the missing semicolon, I totally missed that one... Sorry for that!!
Got it working now, BUT not with an Access-2010 database (extension .accdb ).
So I created a new Access-database with extension .mdb, and that was the last trick.
Thanks for your help!
I found that strange, but tried it. Also the other way around... still a compiling error.
And that was the missing semicolon, I totally missed that one... Sorry for that!!
Got it working now, BUT not with an Access-2010 database (extension .accdb ).
So I created a new Access-database with extension .mdb, and that was the last trick.
Thanks for your help!