Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi As you know when we want to fill DataGridView with a table from a database in SQL we should set a SqlDataAdapter and a DataSet then fill the DataAdapter with DataSet and... same as the code below

C#
SqlDataAdapter DataAdapter1 = new SqlDataAdapter(Command1);
DataSet DataSet1 = new DataSet();
DataAdapter1.Fill(DataSet1, "1");
DataGridView.DataMember = "1";
DataGridView.DataSource = DataSet1;


Now I want to write a code that does the same code as above but in reverse.
Imagine that we have a DataGridView that fills with data, now we want to apply any changes that happened to it into our database in SQL.
Posted
Comments
[no name] 27-Apr-14 9:01am    
Okay... did you have some sort of a question or problem with your code? Did you do any research? Did you read any of the thousands of articles? Did you look at any of the examples?
MohammadHG 27-Apr-14 10:16am    
Yes, I didnt find out any code.
[no name] 27-Apr-14 10:38am    
You would have found tons of code... had you bothered to look.

 
Share this answer
 
you must after loading data in datagridview first of all have a dynamic query for inserting data in sql server.for that's fields you must fetch columns name from data grid view and then fetch values of columns and if there are any condition place it after that execute it.
 
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