473,395 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Why exporting MySQL blob to XML then importing it back doesn't get the same result?

I have some photos (not big, only 8kb) in mysql database (in my desktop). the field type is blob. actually i want to export the table to xml file then upload it to my database website. but it failed. I try to mimic it by exporting the table to xml file then importing it back to another table (the table's structure is same). I can do it but i don't get the same photos (only some encoding text). Here is some pieces of code:

Exporting the table to xml :

Expand|Select|Wrap|Line Numbers
  1. FileStream fs = new FileStream(filename,FileMode.Create,FileAccess.Write,FileShare.None);
  2. StreamWriter sw = new StreamWriter(fs,Encoding.ASCII);
  3. ds.WriteXml(sw);  //write the xml from the dataset ds

Importing the xml to the dataset :


Expand|Select|Wrap|Line Numbers
  1. FileStream fs = new FileStream(filename,FileMode.Open);
  2. DataSet ds = new DataSet();
  3. ds.ReadXml(fs);
Writing the dataset to another table :


Expand|Select|Wrap|Line Numbers
  1.        ...
  2.        int count = ds.Tables[0].Rows.Count;
  3.        for(int i=0;i<count;i++)
  4.        {  
  5.            DataRow myDR = ds.Tables[0].Rows[i];
  6.            ...
  7.            byte[] myphoto = null;
  8.            if(myDR["myphoto"].ToString().Length > 0)
  9.            {
  10.               myphoto = Encoding.ASCII.GetBytes(myDR["myphoto"].ToString().ToCharArray());
  11.            }
  12.            //insert the data to the mysql table 
  13.            ...
  14.        }
  15.        ...
Why i don't get the same photos in this another table?
sorry for my bad english.
Feb 7 '11 #1
0 1258

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Andy Levy | last post by:
Hi there is a function in phpmyadmin that exports all the data etc from a mysql database to an sql text document, or Excel File. I would like to know if there is an inherent way of doing this...
3
by: Sugapablo | last post by:
Is there any PHP function that will allow me to determine the MIME type of a blob stored in MySQL? Specifically, if I'm storing an image as a blob in MySQL, is there any PHP function that can...
7
by: sime | last post by:
Hi, I have a blob field in a mysql database table. I want to copy a blob from one record to another. I am having trouble transferring the data via a php variable. Maybe I need to addslashes or...
1
by: ivenner | last post by:
Hi I am storing a BLOB in a MySQL database, and want to know how to write it out again to a file on the server, in a specified location, in php. Cheers Ian
4
by: cuyler.jones | last post by:
Hello -- I'm having a heck of a time grabbing a blob ( a jpeg image) from a mySQL database and displaying it on a page. I am able to connect to the database and retrieve the data, however...
0
by: estes53 | last post by:
I am trying to pull a wave/riff file from mysql and make it playable. Below is the php which is not working and I have been told that it will not work without referencing a second page, which I...
1
by: sang | last post by:
Hi i am doing my project in Mysql and PHP. My problem is i want to send a Blob field to my email using the Php. That is i am storing Candidates Resume in Blob field(Document format). I want to...
1
by: waleedmazhar | last post by:
Hello Everybody Can anybody tell me when to save images in mysql blob and when save image folder and save the image name in database. which is more better saving image into database or save it...
1
by: cmgmyr | last post by:
Hey All, I'm having a little problem with exporting data from my database. The problem is that the query seems to be too much for PHP and MySQL to handle since it is timing out. I have the timeout...
4
by: foss | last post by:
HI all, I am able to upload the image as blob to mysql. but while displaying the image i cant display it properly . The code used for uploading image to mysql inserts data into mysql table.The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.