title: Inserting Record using DataSet
body: <p>I am developing an application in which I want to insert the data from the DataSet.</p>
  
  <p>Following is my code to Insert the data:</p>
  
  <p>WebForm1.aspx.cs:</p>
  
  <pre><code> public void Recieve_Data()
      {
          DataGridView.DataSource = obj.Get_Data();
          DataGridView.DataBind();
      }
  
      public void Insert_Data()
      {
         TextBox StudentID = DataGridView.FooterRow.FindControl("TxtID") as TextBox;
         TextBox StudentName = DataGridView.FooterRow.FindControl("TxtName") as TextBox;
         TextBox StudentSex = DataGridView.FooterRow.FindControl("TxtSex") as TextBox;
         TextBox StudentCity = DataGridView.FooterRow.FindControl("TxtCity") as TextBox;
  
         int StuID = Convert.ToInt32(StudentID.Text);
         string StuName = StudentName.Text;
         string StuSex = StudentSex.Text;
         string StuCity = StudentCity.Text;
  
         obj.Insert_Data(StuID, StuName,StuSex, StuCity);          
         Recieve_Data();
      }
  </code></pre>
  
  <p>My Insert_Data() is:</p>
  
  <pre><code>public void Insert_Data(int StuID, string StuName, string StuSex, string StuCity)
      {
          adap = new SqlDataAdapter("select * from Student", con);
          DataSet ds = new DataSet();
          adap.Fill(ds,"Student");
  
          DataRow dr = ds.Tables[0].NewRow();
          dr["ID"] = StuID;
          dr["Name"] = StuName;
          dr["Sex"] = StuSex;
          dr["City"] = StuCity;
          ds.Tables[0].Rows.Add(dr);
          ds.Tables[0].AcceptChanges();
      }
  </code></pre>
  
  <p>I am successfully receiving the new inserted record (seventh record) in the dataset at last:</p>
  
  <p><img src="https://i.stack.imgur.com/0wloD.jpg" alt="enter image description here"></p>
  
  <p>But in the database, my table is not updated with the seventh row:</p>
  
  <p><img src="https://i.stack.imgur.com/cakaL.jpg" alt="enter image description here"></p>