Hi Guys,
I have an xml file contains the imagedata attribute. now while reading xml file using dataset i was setting this field to string and insert it to another table that have also image field.
when i am tring to retrive this image it's not a actual image.

<ImageData>/9j/4AAQSkZJRgABAQAAAQABAAD//gA+Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBkZWZhdWx0IHF1YWxpdHkK</ImageData>

Thanks in advance.

Do you mean after you decode the base-64 text it's still not an image? It looks like the start of a JPEG file, and you get "CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality" in the decoded text, but there's nothing after that.

Hi gusano79,
let me explain in detail whats happen

I have a table name Table1 contains img field which is Image datatype. I have store a image in Table1 Now using dataset i have created xml file.

Now i am reading this file with dataset.Readxml() method and inserted image as a string (i think here i am going wrong) in Table2.

Here is my code snippets

Creating XML File

DataSet ds = new DataSet();
            string strxml = "select * from testing123";
            da = new SqlDataAdapter(strxml, connect.getConnection());
            da.Fill(ds, "testing123");
            ds.WriteXml(Application.StartupPath + "\\ImageFile.xml");
            MessageBox.Show("Done");

Now read this file and insert to table2

string ImageTxt = "";
            DataSet ds = new DataSet();
            ds.ReadXml(Application.StartupPath + "\\ImageFile.xml");
            for (int i = 0; i <= ds.Tables[0].Rows.Count-1; i++)
            {
                ImageTxt = ds.Tables[0].Rows[i][0].ToString();
            }

            string strUpdate = "update paper_setting set imagedata='"+ ImageTxt +"'";
            cmd = new SqlCommand(strUpdate, connect.getConnection());
            cmd.Connection.Open();
            cmd.ExecuteNonQuery();
            cmd.Connection.Close();
            MessageBox.Show("Done");

but when i retrieve image from table2. It's not in proper format.

Any help would be appreciated.

This article has been dead for over six months. Start a new discussion instead.