Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ODBC with VC++

ODBC with VC++

Scheduled Pinned Locked Moved C / C++ / MFC
c++saleshelptutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sirtimid
    wrote on last edited by
    #1

    I try to open a table "Customer" and select a specific record of it with the Open property as follows: m_pSet->Open(CCustomer::dynaset,"SELECT NAME FROM CUSTOMER WHERE ID = 5" This command throws the following exception error: "Invalid character value for cast specification" Does anyone know what have I done wrong and how to make it work properly? Thanks in advance

    K 1 Reply Last reply
    0
    • S sirtimid

      I try to open a table "Customer" and select a specific record of it with the Open property as follows: m_pSet->Open(CCustomer::dynaset,"SELECT NAME FROM CUSTOMER WHERE ID = 5" This command throws the following exception error: "Invalid character value for cast specification" Does anyone know what have I done wrong and how to make it work properly? Thanks in advance

      K Offline
      K Offline
      KaRl
      wrote on last edited by
      #2

      Did you try m_pSet->Open(**CRecordSet**::dynaset,_T("SELECT NAME FROM CUSTOMER WHERE ID = 5")) ?


      The great error of nearly all studies of war has been to consider war as an episode in foreign policies, when it is an act of interior politics - Simone Weil Fold with us! ¤ flickr

      S 1 Reply Last reply
      0
      • K KaRl

        Did you try m_pSet->Open(**CRecordSet**::dynaset,_T("SELECT NAME FROM CUSTOMER WHERE ID = 5")) ?


        The great error of nearly all studies of war has been to consider war as an episode in foreign policies, when it is an act of interior politics - Simone Weil Fold with us! ¤ flickr

        S Offline
        S Offline
        sirtimid
        wrote on last edited by
        #3

        Yes I already tried it. I saw that this was because in the DoFiledExchange() the first field must be of the same type with the requested one in the Select clause. Thanks very much for your time! Any idea?

        K 1 Reply Last reply
        0
        • S sirtimid

          Yes I already tried it. I saw that this was because in the DoFiledExchange() the first field must be of the same type with the requested one in the Select clause. Thanks very much for your time! Any idea?

          K Offline
          K Offline
          KaRl
          wrote on last edited by
          #4

          sirtimid wrote: this was because in the DoFiledExchange() the first field must be of the same type with the requested one in the Select claus I watched the source code of the CRecordSet class, the enum being public, I suppose your class can inherit it so your syntax is also correct (even if misleading, but it is just my opinion) I'm not an expert in database access, but I'm not sure the problem comes from this part of code. After some googling[^], I found this: "Typically, this error means the import process is trying to convert (cast) a value in the text file from a character data type to another data type such as numeric or datetime and the value in the text file is not valid for the new data type. "[^] HTH, K.


          The great error of nearly all studies of war has been to consider war as an episode in foreign policies, when it is an act of interior politics - Simone Weil Fold with us! ¤ flickr

          S 1 Reply Last reply
          0
          • K KaRl

            sirtimid wrote: this was because in the DoFiledExchange() the first field must be of the same type with the requested one in the Select claus I watched the source code of the CRecordSet class, the enum being public, I suppose your class can inherit it so your syntax is also correct (even if misleading, but it is just my opinion) I'm not an expert in database access, but I'm not sure the problem comes from this part of code. After some googling[^], I found this: "Typically, this error means the import process is trying to convert (cast) a value in the text file from a character data type to another data type such as numeric or datetime and the value in the text file is not valid for the new data type. "[^] HTH, K.


            The great error of nearly all studies of war has been to consider war as an episode in foreign policies, when it is an act of interior politics - Simone Weil Fold with us! ¤ flickr

            S Offline
            S Offline
            sirtimid
            wrote on last edited by
            #5

            OK I found why this error occured. This was because in the DoFieldExchanged() I have all the fields of the table, so the Open() should be with NULL value at the second argument (LPCTSTR lpszSQL=NULL). So, I tried the following: m_pSet = new CDatabaseSet; m_pSet->m_strFilter = "ID = 48"; m_pSet->Open(CDatabaseSet::dynaset); Now the problem is that it works properly when the filter has a field of numeric type. When it is of character type it doesn't work properly. It returns the last record even if it shouldn't return anything. Any idea on why this happens??? Thanks again for your help!!!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups