Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have populated datagridview control from three tables (with specific columns) of T-SQL.

User will make changes in Datagridview and I have to update that columns.

I am trying the following code:

MIDL
ds.Tables[0].AcceptChanges();
adp.Update(changes);


But it is not working.

Regards!
Aman
Posted
Updated 16-Feb-11 1:35am
v3
Comments
Sunasara Imdadhusen 11-Feb-11 0:31am    
You need to update all tables!

Hi Guys,


Thanx for your supports. I have used the following way to update database with datagridview:
SQL
SqlDataAdapter adp = new SqlDataAdapter();
adp.UpdateCommand = con.CreateCommand();
adp.UpdateCommand.CommandText = "SQlQuery";
adp.UpdateCommand.CommandType = CommandType.Text;
adp.UpdateCommand.Parameters.Add("@a",SqlDbType.VarChar, 50).Value = DataGridView1.Rows[e.RowIndex].Cells[1].Value;
adp.UpdateCommand.Parameters.Add("@AdjAmt", SqlDbType.Float).Value = Convert.ToSingle(DataGridView1.Rows[e.RowIndex].Cells[5].Value);
adp.UpdateCommand.ExecuteNonQuery();
adp.Dispose();


Regards!
Aman
 
Share this answer
 
v2
Hi Aman4.net,

This Question[^] I guess could contains what you are searching for.

I hope this help,
:)
 
Share this answer
 
Hope Update database with DataGridView[^]will give you an idea.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900