here is my code..i cant update my data in my datagridview getting a exception ..im very new to c# please help
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace DataAccsess { public partial class Form1 : Form { SqlConnection sqlcon = new SqlConnection("Data Source=.;Initial Catalog=Rajarata_med_db;Integrated Security=True"); // connection String SqlDataAdapter sqladapter; // sql adapter SqlCommandBuilder commandBuilder; // sql command builder BindingSource bindinglink = new BindingSource(); // binding source DataSet ds = new DataSet(); // dataset public Form1() { InitializeComponent(); // constructor } private void button1_Click(object sender, EventArgs e) // when this button is pressed data will load into the datagridview 1 { sqladapter = new SqlDataAdapter("SELECT * FROM Students", sqlcon); // sending commandBuilder = new SqlCommandBuilder(sqladapter); sqladapter.Fill(ds, "Students"); // fill my dataset dataGridView1.DataSource = ds.Tables["Students"]; // bind datato the datagridview1 bindinglink.DataSource = ds; } private void button2_Click(object sender, EventArgs e) // save changes button { SqlCommandBuilder cm = new SqlCommandBuilder(sqladapter); // getting a error Concurrency violation: the UpdateCommand affected 0 of the expected 1 records. sqladapter.Update(ds.Tables[0]); } } }