Page 1 of 1

How to Isolate Data process

Posted: Wed Dec 12, 2012 7:32 pm
by omayer
Currently I do have usercode module to read test data from sqlserver using sqlDatareader by row, How do I isolate data processing in different module and pass the value to other module , so execution module will not do the data processing, Thank you in Advance

Code: Select all

#region |Method- CreateTordr(string _businessUnit)|

     public void CreateTordr(string _businessUnit)
           
      {
        
            try
            {
               _jobConn.Open();
               
            }
            catch(Exception e)
            {
               Report.Failure(e.ToString());
            }
            
              SqlDataReader myReader = null;        
    
        cmdScenarioId.Parameters.Add(new SqlParameter("businessunit", _businessUnit));
              myReader = cmdScenarioId.ExecuteReader();

             while(myReader.Read())
             {
             
              _businessUnit= myReader["businessunit"].ToString();               

          tempInformation.SelectBusinessUnit(_businessUnit.Trim());
            
      #endregion
   

Re: How to Isolate Data process

Posted: Thu Dec 13, 2012 1:48 pm
by Support Team
Hello,

You could make a 'SQL connector' class to get your data from your database.
Please take a look at our API documentation about 'SQL Data Connectors'.
Please take a look at this post in our forum.

Then, you need to create an instance of this class and use its methods as shown below:
SQLconnector myConn = new SQLconnector()
myConn.RunQuery(string SQL);
Could you please clarify what you want to do?

Regards,
Markus (T)

Re: How to Isolate Data process

Posted: Thu Dec 13, 2012 9:01 pm
by omayer
Thank you Markus, I am trying to read testdata from sql database and then pass as parameter to Method

candidate.firstname(fname) ----i like to get the fname from candidate table and firstname column.

-- Currently i am retrieving data on execution , i want data retrieved in separate class.
say i want to create 10 user, ( user fname will read from sql db) , how to read 1st row then pass the fname to caller , then creating 2nd user will get the fname from 2nd row.

SqlDataReader myReader = null;

cmdScenarioId.Parameters.Add(new SqlParameter("businessunit", _businessUnit));
myReader = cmdScenarioId.ExecuteReader();

while(myReader.Read())
{

_businessUnit= myReader["businessunit"].ToString();

tempInformation.SelectBusinessUnit(_businessUnit.Trim());

Re: How to Isolate Data process

Posted: Mon Dec 17, 2012 5:03 pm
by Support Team
Hello,

I am not sure if I quite catch your issue, but you could make a UserCodeModule where you implement the method which retrieve the data from the sql database. You can call this method every time you want to get some values from the database.
Please check the following link to get more information about creating classes in C#:
http://www.programmersheaven.com/ebooks ... _ebook.pdf
http://www.homeandlearn.co.uk/csharp/csharp.html
You can find a little tutorial how to access data in a sql database at the following link:
http://www.codeproject.com/Articles/441 ... -through-C

Regards,
Bernhard

Re: How to Isolate Data process

Posted: Mon Dec 17, 2012 10:18 pm
by omayer
Thank you for the reference links, these are very helpful. I was trying to read the entire table first then read from the holding place wherever I needed.

Re: How to Isolate Data process

Posted: Tue Dec 18, 2012 9:29 am
by Support Team
Hello,

I'm not sure if the problem is solved now.
Please let me know if you could solve this issue.

Regards,
Bernhard

Re: How to Isolate Data process

Posted: Wed Dec 19, 2012 5:19 pm
by omayer
Sorry i could not solve the issue, I want to create DataProcess class that will read entire data from table in sql db , Then another class will be like order class which will retreived data from DataProcess class as needed. Thank you in Advance

Re: How to Isolate Data process

Posted: Thu Dec 27, 2012 11:47 am
by Support Team
Hello,

Could you please explain which steps you followed to solve your issue?
What exactly is not working?

We could not provide you with a code example for your use case since it is not a Ranorex specific issue.
You could use Linq in order to simplify data access. Please take a look at Linq in MSDN.
A few examples for Linq are shown here.

Regards,
Markus (T)

Re: How to Isolate Data process

Posted: Fri Dec 28, 2012 4:10 pm
by omayer
Thank you Markus, using Linq solved the problem

Re: How to Isolate Data process

Posted: Fri Dec 28, 2012 4:26 pm
by Support Team
Hello,

You are welcome :-)

Regards,
Markus (T)