Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

706 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

18 Experts available now in Live!

Get 1:1 Help Now