nvarchar in crecordset
From: Yan (bytj_at_yahoo.com)
Date: 11/02/04
- Next message: Yaheya Quazi: "Re: Last Login"
- Previous message: Sonya: "Re: Insert into script"
- Next in thread: Sylvain Lafontaine: "Re: nvarchar in crecordset"
- Reply: Sylvain Lafontaine: "Re: nvarchar in crecordset"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 2 Nov 2004 15:00:38 -0500
In my "Customers" table, I have some fields in "nvarchar" type. However,
my program always runs into a problem when the field type is "nvarchar".
Other fields with "char" or "varchar" type works fine. My code snippet is
as follows:
rs.Open(CRecordset::forwardOnly, _T(sqlstmt));
if (! rs.IsEOF())
{
// get the field value
nrs = rs.GetODBCFieldCount();
for (short index = 0; index < nrs; index++)
{
rs.GetFieldValue( index, varVal);
switch(varVal.m_dwType)
{
case DBVT_LONG:
lVal = varVal.m_iVal;
break;
case DBVT_STRING:
szVal = varVal.m_pstring;
break;
default:
// do nothing
break;
}
}
}
In debugging mode, I found it always failed at the line
"rs.GetFieldValue(index, varVal)" when the database table field type is
"nvarchar". It seems that the "DBVT_STRING" is not the correct type for
"nvarchar". How should I fix the problem?
By the way, change the field type "nvarchar" to the type "varchar" is not a
solution for me because I can not change my customer's data structure.
Thanks.
Yan
- Next message: Yaheya Quazi: "Re: Last Login"
- Previous message: Sonya: "Re: Insert into script"
- Next in thread: Sylvain Lafontaine: "Re: nvarchar in crecordset"
- Reply: Sylvain Lafontaine: "Re: nvarchar in crecordset"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|