sankeerth R

sankeerth R

  • NA
  • 105
  • 39.9k

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

Dec 13 2017 7:30 AM
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.