• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

Match data

for(stock->MoveFirst();(!stock->IsEOF())&&(type2!=stock->m_type);stock->MoveNext());
if(type2==stock->m_type)
{
      for(stock->MoveFirst();(!stock->IsEOF())&&(itemn!=stock->m_type);stock->MoveNext());
      if(itemn==stock->m_type)
      {
                                    for(stock->MoveFirst();(!stock->IsEOF())&&(valuen!=stock->m_type);stock->MoveNext());
            if(valuen==stock->m_type)
            {
                  MessageBox("Same data have been found!")
            }
      }
}

else
{
      ...//AddNew()
}


1. I got 3 variables which are  type2, itemn, valuen. All of these used for match the data which the condition is:

      1. type2,itemn can be same which others row of data
      2. *But there of variable (carry the datas) type2,itemn, valuen CANNOT be same in others row

* AT the sametime there of variable which cannot carry the SAME DATA (next new insert data!

My logic above is somethings wrong ....don't know which part!!!
0
DannyGan9
Asked:
DannyGan9
  • 3
  • 2
1 Solution
 
DannyGan9Author Commented:
above question, if i match 2 variables (valuen,itemn) is not problem, when come to three variable, it became troble!!! Got anyone know wat is the error for above coding.....??? TQ!
0
 
Amritpal SinghCommented:
can u plz explain again
what exactly the problem is?
and what are the conditions
0
 
DannyGan9Author Commented:
for(stock->MoveFirst();(!stock->IsEOF())&&(type2!=stock->m_type);stock->MoveNext());
if(type2==stock->m_type)
{
     for(stock->MoveFirst();(!stock->IsEOF())&&(itemn!=stock->m_type);stock->MoveNext());
     if(itemn==stock->m_type)
     {
                              for(stock->MoveFirst();(!stock->IsEOF())&&(valuen!=stock->m_type);stock->MoveNext());
          if(valuen==stock->m_type)
          {
               MessageBox("Same data have been found!")
          }
     }
}

else
{
     ...//AddNew()
}



stock = recordSet
valuen,itemn,type2= variables
============================================

1.I need to match the db(recordSet) dont have a SAME DATA in my recordSet, then i just can insert a new record. Basically i got 3 variables (type2, itemn, valuen) which will carry a data in following example db:-

     type(type2)       value(valuen)        item(itemn)        
1     N                        5                      RD1234 (CANNOT--DUPLICATE)
2     BP                       5                     RD1234
3     N                        10                   RD1234
4      BP                      10                  RD1234
5      N                        5                   RD8899
6      BP                       5                  RD8899
7      N                         5                 RD1234  (CANNOT--DUPLICATE)


Data in row no. 1 and 7 cannot be SAME in row ("N" (type2), "5"(valuen),
"RD1234"(itemn)  ) which is my condition- which cannot one whole row content the SAME data with others (refer dd above). TQ!



0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
allmerCommented:
I am not sure what you are trying to do?
Are you sure that you need the same variable in all three for loops?
That means of course, that within each subsequent call to stock in the
loops you change stock, is that intended?
Maybe you wanna check the whole dataset for the existence of three
specific data members. Than you should do it differently:

bool typetwofound = false,
       itemnfound = false,
       valuenfound = false;
for(stock->MoveFirst();(!stock->IsEOF())&&(type2!=stock->m_type);stock->MoveNext());
if(type2==stock->m_type)
  type2found = true;
if(itemn==stock->m_type)
   itemnfound = true;
if(valuen==stock->m_type)
   valuenfound = true;
}

//Now that all the variables are set and the loop has been finished (one time only)
//apply your logic, however you want:

if(type2found && itmenfound && valuenfound) {
    //do whatever;
}
Hope this helps,
Jens
0
 
allmerCommented:
I assume, that type2,itmen and valuen are a new dataset, that is supposed to be added.
Then use the above and do:
if((type2found == false) && (itemnfound == false)) {
    //add values to record.
}

But maybe I got you wrong and you wanted to do something different like checking if the combination of certain values are present on multiple lines,
than you should probably introduce a variable that holds all three datamembers:
class recordSet {
  public: //make it public for now
  valuen
  type2
  itemn
  recordSet() {};
  ~recordSet(){};
 friend bool operator== (recordSet &lValue, recordSet &rValue) {
    if((lValue.valuen == rValue.valuen) && (lValue.itemn == rValue.itemn))
     return(true);
   return(false);
  }
}
With this data structure yo can easily test wether a recordSet equals another and either ignore it or store it.
Maybe that helps. Overloading operator== is a good idea I guess and having a data structre that holds all of
the variables in your record is also!
Jens
0
 
DannyGan9Author Commented:
My Solution is: -


for(stock->MoveFirst();(!stock->IsEOF()) && (type2 !=stock->m_type) && (itemn != stock->m_item) && (valuen != stock->m_value);stock->MoveNext());
if(type2==stock->m_type && (itemn==stock->m_item ) && (valuen==stock->m_value))
{
....
}

Anywhere Thanks all!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now