?
Solved

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

Posted on 1998-12-04
2
Medium Priority
?
426 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 400 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 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