lianpiau 0 Junior Poster

the problem message as above title. this problem cause when I perform update. When I select record and click update button. It will show the data into above textbox,combobox and picturebox. When I click save button it will pop out the message(title).
Line 32

private void btnSave_Click(object sender, EventArgs e)
        {
            

            OleDbConnection conAuthor;

            ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["MyDBConnectionString"];
            string name = conSettings.ProviderName;
            string providerName = conSettings.ProviderName;
            string ConnectionString = conSettings.ConnectionString;


            conAuthor = new OleDbConnection(ConnectionString);

            OleDbCommand cmdUpdate;
            conAuthor.Open();

            string strUpdate = "Update Mould set POSize=@POSize, TrueSize=@TrueSize, ConfirmDate=@ConfirmDate, Cal1=@Cal1, Cal2=@Cal2,Cal3=@Cal3, Cal4=@Cal4,Cal5=@Cal5, Cal6=@Cal6,img=@img,imgName=@imgName,imgType=@imgType, Return=@Return, Revised=@Revised, Address=@Address where Customer=@Customer and MouldName=@MouldName";

            cmdUpdate = new OleDbCommand(strUpdate, conAuthor);

            
            cmdUpdate.Parameters.AddWithValue("@POSize", txtPOSize.Text);
            cmdUpdate.Parameters.AddWithValue("@TrueSize", txtTrueSize.Text);
            cmdUpdate.Parameters.AddWithValue("@ConfirmDate", dtpConfirmDate.Value);
            cmdUpdate.Parameters.AddWithValue("@Cal1", txtCal1.Text);
            cmdUpdate.Parameters.AddWithValue("@Cal2", txtCal2.Text);
            cmdUpdate.Parameters.AddWithValue("@Cal3", txtCal3.Text);
            cmdUpdate.Parameters.AddWithValue("@Cal4", txtCal4.Text);
            cmdUpdate.Parameters.AddWithValue("@Cal5", txtCal5.Text);
            cmdUpdate.Parameters.AddWithValue("@Cal6", txtCal6.Text);
            cmdUpdate.Parameters.AddWithValue("@img", OleDbType.Binary).Value = imagePic;
            cmdUpdate.Parameters.AddWithValue("@imgName", txtPic.Text);
            cmdUpdate.Parameters.AddWithValue("@imgType", txtType.Text);
            cmdUpdate.Parameters.AddWithValue("@Return", chkReturn.Checked);
            cmdUpdate.Parameters.AddWithValue("@Revised", txtRevised.Value);
            cmdUpdate.Parameters.AddWithValue("@Address", cboAddress.Text);
            cmdUpdate.Parameters.AddWithValue("@Customer", txtCustomer.Text);
            cmdUpdate.Parameters.AddWithValue("@MouldName", txtMouldName.Text);

            cmdUpdate.ExecuteNonQuery();
            conAuthor.Close();
            lblMessage.Text = ("Successful Update!!!");
            timerLoad.Enabled = true;
            txtCustomer.Enabled = true;
            cboAddress.Enabled = true;
            
        }

private void btnUpdate_Click(object sender, EventArgs e)
        {
            btnSave.Enabled = true;
            txtCustomer.Enabled = false;
            cboAddress.Enabled = false;
            
            txtCustomer.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
            txtMouldName.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
            txtPOSize.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
            txtTrueSize.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
            dtpConfirmDate.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
            txtCal1.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
            txtCal2.Text = this.dataGridView1.CurrentRow.Cells[6].Value.ToString();
            txtCal3.Text = this.dataGridView1.CurrentRow.Cells[7].Value.ToString();
            txtCal4.Text = this.dataGridView1.CurrentRow.Cells[8].Value.ToString();
            txtCal5.Text = this.dataGridView1.CurrentRow.Cells[9].Value.ToString();
            txtCal6.Text = this.dataGridView1.CurrentRow.Cells[10].Value.ToString();

            Byte[] byteBLOBData = new Byte[0];
            byteBLOBData = (Byte[])(dataGridView1.CurrentRow.Cells[11].Value);
            MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
            pictureBox1.Image = Bitmap.FromStream(stmBLOBData);

            txtPic.Text = this.dataGridView1.CurrentRow.Cells[12].Value.ToString();
            txtType.Text = this.dataGridView1.CurrentRow.Cells[13].Value.ToString();
            cboAddress.Text = this.dataGridView1.CurrentRow.Cells[14].Value.ToString();
        }

private void btnGetImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Image Files(*.png; *.jpg; *.bmp)|*.png; *.jpg; *.bmp";
            if (open.ShowDialog() == DialogResult.OK)
            {
                fileName = System.IO.Path.GetFullPath(open.FileName);
                pictureBox1.Image = new Bitmap(open.FileName);
                this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;

                
                
                
                //set the picture name to textBox:
                onlyName = System.IO.Path.GetFileName(fileName);
                string[] seperate = onlyName.Split('.');
                txtPic.Text = seperate[0];
                txtType.Text = seperate[1];
                txtPic.Focus();
                txtPic.SelectionStart = txtPic.Text.Length;
                

                //get byte array of the image:
                imagePic = System.IO.File.ReadAllBytes(fileName);
            }
        }
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.