Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Match data

Posted on 2004-10-29
6
Medium Priority
?
167 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
Comment
Question by:DannyGan9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Author Comment

by:DannyGan9
ID: 12450644
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
ID: 12450673
can u plz explain again
what exactly the problem is?
and what are the conditions
0
 

Author Comment

by:DannyGan9
ID: 12451746
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
allmer earned 400 total points
ID: 12453410
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
ID: 12453465
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
ID: 12460339
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

604 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