dotnet academic:
Hello, im having a problem and i would like some help=2E I ll try describe= my situation=2E I have a database table with two fields, one is a varchar and the other is an image field=2E the image field= is used to store documents in byte stream format=2E What i need to= do is export all data from that table and import it to a similar= table on a different database=2E The way im doing that is= exporting all the data into xml files and then i read the xml= files and put the data into the database i want to import data= into=2E I need to do it that way bcos the import will not take= place str8 after the export (otherwise could all be done in= stored procedures)=2E My problem is reading the image field from= the xml=2E The xml field that holds a document as byte stream= looks like that: <Letter_template>0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7=2E=2E=2Emore= data here=2E=2E=2E=2E</Letter_template> I read the xml using XmlTextReader=2E The problem is that all= values are read as strings form the xml (obviously)=2E but to= insert the <Letter_template> into the database field i need it= as a byte[]=2E if i try to cast the string it doesn't work=2E For= example im reading the value doing the following: XmlTextReader reader =3D new XmlTextReader("xmlFilePath"); while (reader=2ERead()) { // found <letter_Template> tag // read content string string_byte_array =3D reader=2EValue; // returns string= anyway int numBytes =3D (int) string_byte_array=2ELength; byte[] letter_template =3D new byte[numBytes]; // how the heck im i gonna put the string into the byte []= array? } hope you have understood my problem=2E how the heck, am i gonna read a string that already contains a= byte stream (as a string representation), into a byte[] without= encoding it further=2E=2E=2E Thanx for reading my problem=2E=2E=2E PS: Sorry for my english :) -------------------------------- From: Andreas N=2E ----------------------- Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)
Use Convert.ToBase64. It converts binary data to and from text without a loss of prescision. There is also a FromBase64. -- Eric Marvets Principal Consultant the bang project <shameless self promotion> Email sales@bangproject.com for Information on Our Architecture and Mentoring Services </shameless self promotion>
Don't see what you're looking for? Try a search.
|