Solved

using toupper() with m_pSet-> ODBC, VC++4.0

Posted on 1998-12-04
2
423 Views
Last Modified: 2008-03-03
In this code, I'm doing a search...taking 5 member variables that are pointed to by the m_pSet-> pointer, then putting them into a CString variable, to then compare what was entered in a search string edit box. It might not be the best way to go, but it works...VC++ 4.0 doesn't have find functions in it. My problem is, I want to take the CString data in the fields and the CString data entered as search criteria in the search edit box, and convert them both to upper before doing a search, because the data could be in either case. I tried using the toupper() function, but I'm having a problem because I need to take a CString variable as my source. Can you help me out? Any other way of doing this? Again I'm using Microsoft VC++ ver4.0. Thanks!
Here is my code, excluding any conversion attempts. Got any suggestions? I want to start conversion after I attribute the m_pSet-> pointers to CString variables.

void CPieces3CLRView::OnGoCheckBox()
{
      //Transfer find edit box string to variable
      UpdateData(TRUE);      
      //Move to the first record
      m_pSet->MoveFirst();
      Nrec=0;      //number of records set to zero before count.
      
      //***************
      //Count number of records in recordset
      CPieces3CLRSet rsPieces3CLRSet(NULL);
      rsPieces3CLRSet.Open( );      
      while(!rsPieces3CLRSet.IsEOF())
      {
            rsPieces3CLRSet.MoveNext();
            //Nrec is number of records; external variable
            //seen to whole file
            Nrec+=1;
      }
      rsPieces3CLRSet.Close();
      //***************
      //Index is external; seen by whole file.
      for(Index=1;Index<Nrec;Index++)
      {
            //line 100***Put first field data into a                  //string variable
//This is where i must convert the variables to uppercase
            CString strMarque =m_pSet->m_MARQUE;      
            CString strModele = m_pSet->m_MODELE;
            CString strPiece = m_pSet->m_PIECE;
            CString strDescription = m_pSet->m_DESC;
            CString strTiroir = m_pSet->m_TIROIR;
      
            
            

            //Compare string variable with edit box data                 //variable
            if(strMarque == m_SearchEditBox)
            {
                  //Display current record
                  UpdateData(FALSE);
                  MessageBeep((WORD)-1);
                  break;
            }
            if(strModele == m_SearchEditBox)
            {
                  //display current record
                  UpdateData(FALSE);
                  MessageBeep((WORD)-1);
                  break;
            }

            if(strPiece == m_SearchEditBox)
            {
                  //display current record
                  UpdateData(FALSE);
                  MessageBeep((WORD)-1);
                  break;
            }

            if(strDescription == m_SearchEditBox)
            {
                  //display current record
                  UpdateData(FALSE);
                  MessageBeep((WORD)-1);
                  break;
            }            
            m_pSet->MoveNext();            
      }
      m_DerniereRechercheEditBox = m_SearchEditBox;
      m_SearchEditBox= "";      
      m_ctlSearchEditBox.SetReadOnly(TRUE);
      m_GoCheckBox = FALSE;      
      UpdateData(FALSE);      
      return;

      
      
}
0
Comment
Question by:pigeonbr
[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
2 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 total points
ID: 1179220
toupper only converts a single character

e.g.
char c = toupper( 'a' ) ; // c is now 'A'

use MakeUpper (member of CString) to convert a string to uppercase

CString abc = "abc" ;
abc.MakeUpper() ; // abc is now "ABC"

you can do this on any CString, e.g. if m_pSet->m_strWhatever is your string

m_pSet->m_strWhatever.MakeUpper() ;

0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1179221
Well, pigeonbr, this may solve the problem
0

Featured Post

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!

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

724 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