티스토리 뷰

카테고리 없음

c# SQLite에서 이미지 로드하기

뽀로로친구에디 2019. 1. 23. 13:48

void item_image_load()  //이미지 로드

        {

            string Query = "select * from factory where part='" + this.comboBox2.Text + "';";


            SQLiteCommand cmdDataBase = new SQLiteCommand(Query, cn);

            SQLiteDataReader myReader;



            try

            {

                cn.Open();

                myReader = cmdDataBase.ExecuteReader();


                while (myReader.Read())

                {

                    byte[] imgg = (byte[])(myReader["item_image"]);

                    if (imgg == null)

                        this.pictureBox1.Image = null;

                    else

                    {

                        MemoryStream mstream = new MemoryStream(imgg);

                        this.pictureBox1.Image = System.Drawing.Image.FromStream(mstream);

                    }


                }

                cn.Close();


            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }


        }

댓글
최근에 달린 댓글
글 보관함
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Total
Today
Yesterday
    뽀로로친구에디
    최근에 올라온 글