Solved

Match data

Posted on 2004-10-29
164 Views
Last Modified: 2013-11-20
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
Question by:DannyGan9
    6 Comments
     

    Author Comment

    by:DannyGan9
    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
     
    LVL 6

    Expert Comment

    by:Amritpal Singh
    can u plz explain again
    what exactly the problem is?
    and what are the conditions
    0
     

    Author Comment

    by:DannyGan9
    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
     
    LVL 5

    Accepted Solution

    by:
    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
     
    LVL 5

    Expert Comment

    by:allmer
    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
     

    Author Comment

    by:DannyGan9
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This video discusses moving either the default database or any database to a new volume.

    845 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now