narasiman rao

narasiman rao

  • NA
  • 519
  • 762.4k

how to update the command using oledb in csharp in windows

Feb 14 2013 8:49 AM
  how to update the command using oledb in csharp in windows application.


 Faculty code       textbox
 Faculty Name     textbox
Allocated hours   textbox

       
       Save code as follows;

        private Globalfunction GFun = new Globalfunction();
        private string sql;
       



 sql = "insert into Tb_Faculty_Details ([Faculty_Code], [Faculty_Name],[Allocated_Hours]) " + " values('" + txt_Faccode.Text + "','" + Txt_Facname.Text + "', " + txt_Hrs.Text + ")";
            try
            {
                GFun.error = "";
                GFun.InsertAccessData(sql);
                if (GFun.error.ToString() != "")
                {
                    MessageBox.Show(GFun.error.ToString(), "Error");
                    return;
                }

                GFun.OleDbcon.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


Update code as follows;


 sql = "Update Tb_Faculty_Details set (Allocate_hours = '" + txt_Hrs.Text + "')  where Faculty_Code = ' " + txt_Faccode.Text + "'";
            try
            {
                GFun.error = "";
                GFun.InsertAccessData(sql);
                if (GFun.error.ToString() != "")
                {
                    MessageBox.Show(GFun.error.ToString(), "Error");
                    return;
                }

                GFun.OleDbcon.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
i want to update only allocated hours after searching the record, i want to update the allocated hours.



Answers (1)