Click here to Skip to main content
12,955,493 members (67,926 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Four Fields as follows in run mode;
Course Code     textbox
Course Name     textbox
course duration textbox
Allocated hours textbox

Threee button as follows;
Save  Search  Update

1. Save code as follows;
        private Globalfunction GFun = new Globalfunction();
        private string sql;
  private void Btn_Save_Click(object sender, EventArgs e)
            sql = "insert into Tb_course_Details ([Course_Code],[Course_Name],[Course_Duration],[Allocated_Hours]) " + " values( ' " + txt_coursecode.Text + "','" + txt_coursename.Text + "', " + txt_courseduration.Text + "," + txt_Allochrs.Text + ")";
                GFun.error = "";
                if (GFun.error.ToString() != "")
                    MessageBox.Show(GFun.error.ToString(), "Error");
            catch (Exception ex)
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

2. Search code as follows;
private void Btn_Search_Click(object sender, EventArgs e)
                sql = "select  * from Tb_course_Details  order by Course_Code";
                OleDbDataAdapter da = new OleDbDataAdapter(sql, GFun.OleDbcon);
                DataTable dt = new DataTable();
                DGVCourseDetails.DataSource = dt;
            catch (Exception ex1)
                MessageBox.Show(ex1.ToString(), "Error", MessageBoxButtons.OK);

3. datagridviewcell click code as follows;
private void DGVCourseDetails_CellClick(object sender, DataGridViewCellEventArgs e)
         txt_coursecode.ReadOnly = true;
         txt_coursecode.Text = DGVCourseDetails.Rows[e.RowIndex].Cells[0].Value.ToString();
         txt_coursename.Text = DGVCourseDetails.Rows[e.RowIndex].Cells[1].Value.ToString();
         txt_courseduration.Text = DGVCourseDetails.Rows[e.RowIndex].Cells[2].Value.ToString();
         txt_Allochrs.Text = DGVCourseDetails.Rows[e.RowIndex].Cells[3].Value.ToString();


when i click the datagridveiw,the respective entries will be displayed in the textbox.
that is working fine.

i want to update the course duration and Allocated hours.
for that in the update button how can i do using c sharp.

Update Button.
private void Btn_Update_Click(object sender, EventArgs e)
       In Update Button how can i write the code to update course duration and  Allocated hours.

please help me.

how can i write the code to update the course duration and allocated hours.

Regards and Thanks.
Narasiman P.
Posted 14-Feb-13 1:36am
Updated 14-Feb-13 2:00am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

What is the issue? All you need is to write an update query using ADO.NET
Following article will help you learn: Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^]

Try out!
Member 8054539 14-Feb-13 8:33am
not to update the code using ADO.NET.
i want to write the Update Code using oledb

for that how can i update the code using csharp.
Sandeep Mewara 14-Feb-13 8:57am
Read the link above and these too:
MSDN: Accessing Data with ADO.NET[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,719
CHill60 3,550
Maciej Los 3,153
ppolymorphe 2,060
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100