---
title: "how achieve batch update data"  
description: "how achieve batch update data"  
author: "Kenny Tangnde"  
published: 2012-01-31  
updated: 2012-02-01  
canonical: https://www.mindstick.com/forum/380/how-achieve-batch-update-data  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# how achieve batch update data

hi all,

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to achieve [batch](https://www.mindstick.com/forum/157604/explain-the-features-of-the-batch-operating-system-also-describe-the-pros-and-cons) [update data](https://answers.mindstick.com/qa/104791/how-to-update-data-in-oracle), but [failed](https://www.mindstick.com/forum/160484/error-failed-to-launch-debug-adapter-additional-information-may-be-available-in-the-output-window) to achieve, give correction, the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) is as follows\
thank in advance.

```
 public partial class UpdateTranData : Form    {        public UpdateTranData()        {            InitializeComponent();        }        SqlDataAdapter adapter;        DataSet ds;        string connectionString = @"data source=StudentDB;initial catalog=MYDB;user=sa;password=PASSWORD;";        SqlConnection sqlCnn;        SqlCommand sqlCmd;        string sql = null;        private void UpdateTranData_Load(object sender, EventArgs e)        {            sql="SELECT *FROM TRAN_INFO";            sqlCnn = new SqlConnection(connectionString);            sqlCnn.Open();            adapter = new SqlDataAdapter(sql, sqlCnn);// specifing SQL statement and Database connection            ds = new DataSet();//creating instance of DataSet            adapter.Fill(ds); //filling DataSet            dataGridView1.DataSource = ds.Tables[0];//Binding DataGridView with DataSet                    }              private void btnUpdate_Click(object sender, EventArgs e)       {                      SqlCommandBuilder scb = new SqlCommandBuilder(adapter);           if (MessageBox.Show("Are you sure?","Warning",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)==DialogResult.Yes)           {               try               {                   adapter.Update(ds.Tables[0]);                   sqlCnn.Close();                   MessageBox.Show("Data updated successful!");                                  }               catch (Exception)               {                   MessageBox.Show("Data updated defeat!");                   sqlCnn.Close();               }           }           private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)        {           txtID.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();           txtStart_Station.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();           txtEnd_Station.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();           txID.Enabled = false;        }   }
```

## Replies

### Reply by James Smith

Hi Aken,\
I checked your code. It's working fine. Could you tell me exception or error which you are getting in program so I can understand exact problem.\
\
Thanks.


---

Original Source: https://www.mindstick.com/forum/380/how-achieve-batch-update-data

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
