Click here to Skip to main content
15,032,256 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:

I failed to convert following 2 type of data into readable record by using following code. This data migrated from lotus note to sql server by using LEI.
Anyone know how?

in image data type:

in binary data type:

string sqlText = "..."
 SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ToString());
        SqlCommand command = new SqlCommand(sqlText, connection);

        //open the database and get a datareader
        SqlDataReader dr = command.ExecuteReader();
        if ( dr.Read()) //yup we found our image
const int CHUNK_SIZE = 2 * 1024;
       byte[] buffer = new byte[CHUNK_SIZE];
       long bytesRead;
       long fieldOffset = 0;
       using (var stream = new MemoryStream())
           while ((bytesRead = dr.GetBytes(dr.GetOrdinal("checklist"), fieldOffset, buffer, 0, buffer.Length)) > 0)
           // while ((bytesRead = dr.GetBytes(dr.GetOrdinal("CCList"), fieldOffset, buffer, 0, buffer.Length)) > 0)
               stream.Write(buffer, 0, (int)bytesRead);
               fieldOffset += bytesRead;

Updated 1-Jan-13 21:31pm

I would like to convert the above data to readable text. Those data already in my database.
Above code did not work. Please help!
what exactly do you want to do?
I think you want to save a image to a database and then retrieve it?

import: load your image, then convert it to a byte-array and then you can add it into your db..
orm you can convert the byte array into a base64-string?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900