Hi,

so yeah. what i'm trying to do is load an image from my database create some graphics to it. probably just some lines and marks and save it back to my database. here's so far what I got.

for creating graphics:

 }

        private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
        {
            draw = true;
        }

        private void pictureBox3_MouseMove(object sender, MouseEventArgs e)
        {
            if (draw)
            {
                Graphics g = Graphics.FromImage(pictureBox3.Image);
                g.FillEllipse(color, e.X, e.Y, 25, 25);
                pictureBox3.Invalidate();


            }

        }

        private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
        {
            draw = false;
        }

and for saving it:

}
private void button15_Click(object sender, EventArgs e)
        {

            Image img = pictureBox3.Image;
            byte[] byteImg = ImageToByteArray(img);
                    OleDbConnection oleDbConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\Asthred\\Documents\\sad\\Sad.mdb");
            OleDbCommand oleDbCommand = new OleDbCommand();
            oleDbCommand.Connection = oleDbConnection;
            oleDbCommand.CommandText = "UPDATE Patientsinformation SET Toothchart = @image   WHERE Lastname= @tb58 AND Firstname= @tb58 ";
            oleDbCommand.Parameters.AddWithValue("@image", byteImg);
            oleDbCommand.Parameters.AddWithValue("@tb58", tb58.Text);
            oleDbCommand.Parameters.AddWithValue("@tb57", tb57.Text);
            oleDbConnection.Open();
            oleDbCommand.ExecuteNonQuery();
            oleDbConnection.Close();
            MessageBox.Show("Record Updated!");
            this.patientsinformationTableAdapter.Fill(this.sadDataSet.Patientsinformation);
        }

but the saving part doesnt work :( I think it only saves the image loaded to the picturebox but not the graphics created to it. how to merge it? i've tried to google it and found some sort of same cases but fails to make it work, something like converting it to bitmap. first time c# user by the way so yeah sort of ahh, having a hard time. thanks by the way in advance. help :((

Hi dws.ash1, welcome at DaniWeb.
Perhaps you could use the CopyFromScreen method from the Graphics class.

Thanks :)) I got it fixed by the way by using the bitmap converting thingyy :)) anyway thanks again for the reply :)

private void pictureBox3_MouseMove(object sender, MouseEventArgs e)
        {
            if (draw)
            {
                Image pic = pictureBox3.Image;
                Bitmap bmp = new Bitmap(pic);
                Graphocs g = Graphics.FromImage(bmp);
                g.FillEllipse(color, e.X, e.Y, 5, 5);
                pictureBox3.Image = bmp;
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.