Good day!
There is a MySQL database located on the server. In one of the database tables, data is presented in blob format (binary xml representation). I need to isolate this data and present it to the user, displaying it in richtextbox.
Immediately I say that I never had to work with xml, but this task should be solved right now.
There was a naive variant to derive everything as usual, but it turned out to be useless:
static string connectionString = "тут путь до сервера"; static MySqlConnection connection = new MySqlConnection(connectionString); string query = "SELECT ReqData, AnsData FROM tab_482 WHERE Npp = 545" ; connection.Open(); MySqlCommand command = new MySqlCommand(query, connection); MySqlDataReader reader = command.ExecuteReader(); richTextBox1.Text = reader["ReqData"].ToString(); richTextBox2.Text = reader["AnsData"].ToString(); reader.Close(); connection.Close(); After visiting several sites, it became clear that you need to use a special reader for xml, but in those examples you refer directly to the file, and how to specify the path to the table cell via the SQl query ...
There was another option:
byte[] barray = Encoding.Unicode.GetBytes(((reader["ReqData"]).ToString()).ToCharArray()); string str = Encoding.Unicode.GetString(barray); richTextBox1.Text = str; but in both cases only System.byte[] is displayed.
Tell me, how can I get the data from the database so that the user sees the xml code?
ToString()andToCharArray()are not needed - Andrey NOPSystem.Text.Encoding.Default.GetString(reader["ReqData"])- Andrew NOPvar reqBytes = (byte[] reader["ReqData"];)- tym32167reader["ReqData"]hasobjecttype, so the compiler swears that theobjectinbyte[]cannot be overtaken - Violofan