ODBC with VC++
-
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
-
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
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
-
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
-
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?
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
-
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
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!!!