c# - Store and retrieve rtf character codes into sql database -


how can retrieve character codes when datatype varbinary. gave "system.byte[]" string. here code:

    public string gettexttext(string name)     {         datatable mydata = new datatable();         sqlitecommand cmd;         sqlitedataadapter adptr = new sqlitedataadapter(); ;         sqliteconnection con = new sqliteconnection("data source=database.db;version=3;new=false;compress=true;");         con.open();         cmd = con.createcommand();         string sql = "select * parent name ='" + name + "' ";         cmd.commandtext = sql;         adptr.selectcommand = cmd;         adptr.fill(mydata);         con.close();         return mydata.rows[0][1].tostring();     } 

as explained here: varbinary string

it depends on how inserted database in first place:

// if original encoding ascii  return encoding.ascii.getstring(mydata.rows[0][1]);   // if original encoding utf-8  return encoding.utf8.getstring(mydata.rows[0][1]);   // if original encoding utf-16  return encoding.unicode.getstring(mydata.rows[0][1]); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -