Yuki_1 0 Newbie Poster

Hi, in my project i need to update the attn_dateTimeOut in database.After i updated it will automatic delete the specific row record that had been updated.
I had two question:

1) in my database there are a few table is assign not null."attn_dateTimeOut" is a table that haven insert any record.When i update it using below code,it work and can update but it comes out error.Error show "record cannot be null".

2) I want t make it when i updated the "attn_dateTimeOut",it will auto delete the row of updated record.I do usign back code "DeleteRecord" but it nothing change!How should i do?

here my code

 private void txt_proximity_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                TMPB_attn row_TMPN_attn = BusinessLogicLayer.TMS_GET_PROXIMITY_VALID_TO_USE(txt_proximity.Text);
                if (!String.IsNullOrEmpty(txt_proximity.Text))
                {
                    using (TMPB_attn_DAL dalObj = new TMPB_attn_DAL())
                    {
                        if (row_TMPN_attn != null)
                        {
                            try
                            {
                                row_TMPN_attn.attn_dateTimeOut = Convert.ToDateTime(DateTime.Now);
                                dalObj.UpdateRecord(row_TMPN_attn);
                                dalObj.DeleteRecord();
                                MessageBox.Show("Update Successful");
                                txt_proximity.Text = "";
                                loadGridView();
                            }
                            catch (Exception es)
                            {
                                MessageBox.Show(es.Message);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Proximity No. is not exist");
                            txt_proximity.Text = "";
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please try again");
                    txt_proximity.Text = "";
                }
            }
        }
Be a part of the DaniWeb community

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