Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void toolStripButton1_Click(object sender, EventArgs e)
        {
            // open file dialog
            OpenFileDialog open = new OpenFileDialog();

            // image filters
            open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
            open.FilterIndex = 2;
            if (open.ShowDialog() == DialogResult.OK)
            {
                

                using (SqlCeCommand cmd = new SqlCeCommand("INSERT into imag(image)VALUES(@image)", con))
                {
                    Stream fileStream = open.OpenFile();

                    
                    fileStream.CopyTo(ms);
                    byte[] a = ms.GetBuffer();

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@image", a);

                    cmd.ExecuteNonQuery();
                  
                    this.imagTableAdapter.Fill(this.bb1DataSet.imag);
                    this.imagBindingSource.MoveLast();
                   
                }
Posted
Updated 3-Nov-15 3:00am
v2
Comments
Joshi, Rushikesh 3-Nov-15 11:40am    
Where is code for binding image on ImageBox, surely you are keep debugging and trying to see Image on screen.

Note: while debugging UI is not getting refreshed as ReRender event will not fire which refreshes the UI, check it without debugging and see whether it is still happening or not.

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