Пример #1
0
        /*        private byte[] imageToByteArray(Image img)
         *      {
         *          ImageConverter imageConverter = new ImageConverter();
         *          byte[] b = (byte[])imageConverter.ConvertTo(img, typeof(byte[]));
         *          return b;
         *      }*/



        private void button2_Click(object sender, EventArgs e) //저장 버튼
        {
            conn = new OleDbConnection(connectionString);
            try
            {
                conn.Open(); //데이터베이스 연결
                OleDbCommand cmd = new OleDbCommand();
                if (image == null)
                {
                    cmd.CommandText = "INSERT INTO movie VALUES('M'||to_char(M_N.nextval,'FM000'),'" + textBox2.Text + "','" +
                                      textBox4.Text + "','" + textBox5.Text + "', NULL, '0')";
                }
                else
                {
                    cmd.CommandText = "INSERT INTO movie VALUES('M'||to_char(M_N.nextval,'FM000'),'" + textBox2.Text + "','" +
                                      textBox4.Text + "','" + textBox5.Text + "', :image_var, '0')";


                    byte[]         bytes = imageToByteArray(image);
                    OleDbParameter para  = new OleDbParameter();
                    para.OleDbType     = OleDbType.LongVarBinary;
                    para.ParameterName = ":image_var";
                    para.Direction     = ParameterDirection.Input;
                    para.SourceColumn  = "product_image";
                    para.Size          = bytes.Length;
                    para.Value         = bytes;
                    cmd.Parameters.Add(para);
                }

                cmd.CommandType = CommandType.Text;
                cmd.Connection  = conn;
                cmd.ExecuteNonQuery(); //쿼리문을 실행하고 영향받는 행의 수를 반환.
                cmd.Parameters.Clear();
                conn.Close();
                textBox2.Text = "";
                textBox4.Text = "";
                textBox5.Text = "";
                image         = null;
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message); //에러 메세지
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close(); //데이터베이스 연결 해제
                }
            }
            Dispose(true);
            Admin_Movie frm = new Admin_Movie();

            frm.ShowDialog();
        }
Пример #2
0
        private void button2_Click(object sender, EventArgs e) //영화 관리
        {
            Admin_Movie frm = new Admin_Movie();

            frm.ShowDialog();
        }