Click here to Skip to main content
15,887,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void button1_Click(object sender, EventArgs e)
    {
        OleDbConnection myConnection = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
 
        myConnection.Open();
        OleDbCommand cmd = new OleDbCommand("select * from [Images] where ID=1", myConnection);
        OleDbDataAdapter da = new OleDbDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
 
        if (dt.Rows.Count > 0)
        {
            if (dt.Rows[0]["AImage"] != DBNull.Value)
            {
                pictureBox.Image = ByteArrayToImage((Byte[])dt.Rows[0]["AImage"]);
            }
        }
        myConnection.Close();   
 
    }
 
    Bitmap ByteArrayToImage(byte[] b)
    {
        MemoryStream ms = new MemoryStream();
        byte[] pData = b;
        ms.Write(pData, 0, Convert.ToInt32(pData.Length));
        Bitmap bm = new Bitmap(ms, false);
        ms.Dispose();
        return bm;
    }

datatype of the data field is oledbobject
Posted
Updated 24-Oct-13 19:29pm
v2
Comments
ArunRajendra 25-Oct-13 1:31am    
In which line are you getting this error?

1 solution

 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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