0
Answer

GetBytes method for Text, NText, or Image not for nvarchar?

sankeerth R

sankeerth R

6y
246
1
The GetBytes function can only be used on columns of type Text, NText, or Image but not for nvarchar datatype.
 
byte[] outbyte = new byte[dr.GetBytes(dr.Getordinal["Notes"], 0, null, 0, 0)];
long y = dr.GetBytes(dr.Getordinal["Notes"], 0, outbyte, 0, 1000);
encodedtext = Encoding.UTF8.GetString(outbyte);
 
exception i got is The GetBytes function can only be used on columns of type Text, NText, or Image but not for nvarchar datatype.
 
Note: Here "Notes" column is a nvarchar type.