I am working at winforms project and i have a datagridview from which i am trying to update a database from it when the user changes something. Here is the code:

DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["EbosPr.Properties.Settings.Database1ConnectionString1"].ConnectionString);
SqlCommand scmd = new SqlCommand("Select * From CustCalls ", conn);
SqlDataAdapter sda = new SqlDataAdapter(scmd);

sda.Fill(ds);

DataTable dt = ds.Tables[0];
this.dataGridView1.BindingContext[dt].EndCurrentEdit();
SqlCommandBuilder myBuilder = new SqlCommandBuilder(sda);

myBuilder.GetUpdateCommand();

sda.UpdateCommand = myBuilder.GetUpdateCommand();
sda.Update(dt);

The above code doesnt update the database. Any idea?

hello!
how can this code update database :P you are using select statement instead of update :)

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.