[VC6, DAORecordSet.SetValue()] 
Author Message
 [VC6, DAORecordSet.SetValue()]

What I've got:
    I'm using VC6 and DAO 3.51.
What I'm doing:
    I'm reading data out of a text file (non-unicode) into CStrings, and
then using DaoRecordSet's SetValue function to put the string into an MDB
table.
The problem is:
    that DAORecordSet.SetValue() takes a Variant, and when I convert the
CString I read in into a Variant, the Variant is a Unicode Variant.
My database, however, is not a Unicode database. Soooo, when I try to put a
20 Unicode-character string into a 20-standard character string field, DAO
throws the exception "String too long for field".

I even tried to force conversion to a VT_BSTRT (which should be a
non-unicode string variant) this way:
    //(sValue is a CString, and varValue is a COleVariant)
    varValue = COleVariant( sValue, VT_BSTRT );
I end up with a Variant that is: {"" VT_BSTR}

I searched my project for _UNICODE or _MBCS, and neither is in there, so,
according to the docs (as far as I can tell), MFC should be using ANSI
(1-byte characters), not Unicode (2-byte characters).

I would like to use the DAORecordset members (e.g. m_MyString) and avoid
this problem altogether, but I'm writing an import routine that maps import
columns to Recordset columns, and I'd really like to avoid writing a huge
switch() statement to map the imported column to the correct DAORecordset
column - which is why I'm using myRecordset.SetValue( sColumnName, varValue)
instead....

Any ideas?

Help?



Fri, 08 Mar 2002 03:00:00 GMT  
 [VC6, DAORecordSet.SetValue()]
Farzad,

I'm having EXACTLY the same problem.  Have you found a solution?

Thanks,



Quote:
> What I've got:
>     I'm using VC6 and DAO 3.51.
> What I'm doing:
>     I'm reading data out of a text file (non-unicode) into CStrings,
and
> then using DaoRecordSet's SetValue function to put the string into an
MDB
> table.
> The problem is:
>     that DAORecordSet.SetValue() takes a Variant, and when I convert
the
> CString I read in into a Variant, the Variant is a Unicode Variant.
> My database, however, is not a Unicode database. Soooo, when I try to
put a
> 20 Unicode-character string into a 20-standard character string field,
DAO
> throws the exception "String too long for field".

> I even tried to force conversion to a VT_BSTRT (which should be a
> non-unicode string variant) this way:
>     //(sValue is a CString, and varValue is a COleVariant)
>     varValue = COleVariant( sValue, VT_BSTRT );
> I end up with a Variant that is: {"" VT_BSTR}

> I searched my project for _UNICODE or _MBCS, and neither is in there,
so,
> according to the docs (as far as I can tell), MFC should be using ANSI
> (1-byte characters), not Unicode (2-byte characters).

> I would like to use the DAORecordset members (e.g. m_MyString) and
avoid
> this problem altogether, but I'm writing an import routine that maps
import
> columns to Recordset columns, and I'd really like to avoid writing a
huge
> switch() statement to map the imported column to the correct
DAORecordset
> column - which is why I'm using myRecordset.SetValue( sColumnName,
varValue)
> instead....

> Any ideas?

> Help?

Sent via Deja.com http://www.deja.com/
Before you buy.


Sun, 31 Mar 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. RegistryKey.SetValue and null strings

2. SetValue with multidimensional array

3. Array.SetValue and COM interface

4. dbDAO, QueryDefs and SetValue Problems

5. How To use CDynamicAccessor::SetValue() ?

6. How To use CDynamicAccessor::SetValue() ?

7. How to use SetValue in OLEDB

8. Problem when setvalue to an MDB database

9. CDynamicAccessor::SetValue with a TCHAR??

10. Why Very very slow Parameter->SetValue( )

11. CDynamicAccessor::SetValue( TCHAR ) ??????

12. CDynamicAccessor::SetValue & TCHAR

 

 
Powered by phpBB® Forum Software