Solved

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

Posted on 1998-12-04
2
398 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

863 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

19 Experts available now in Live!

Get 1:1 Help Now