Click here to Skip to main content
11,802,222 members (48,067 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# SQL-Server Visual-Studio , +
I have a datagridview filled with a table of my database in my winforms Application.

Then I want to save datagridview to my database when I make changes to datagridview. I'm using sql Database.

Here is my code:

DataTable allData = new DataTable();
SqlCommand cmd = new SqlCommand("Select * from contactTable", Connection);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);

But nothing happens with this code.

At last I used insert statrements to enter the dataGridView to my database.
Posted 14-Aug-12 3:46am
Edited 15-Aug-12 8:43am
Wes Aday at 14-Aug-12 9:56am
"I searched a lot but nothing helped me"... in other words, you did not try very hard. There are tons of examples on the web and even here on CP doing this very thing. This question is asked every other day. And you could not find anything? What have you tried? What errors do you get? Where is the code that demonstrates any kind of a problem?
Pooya F.A at 14-Aug-12 10:00am
well let me introduce you. I may use TableAdapter and DataTable but nothing happens at all. Another way is updating TableAdapter by newRow().
Wes Aday at 14-Aug-12 10:09am
So you post code that does not do anything and has nothing to do with your question?
Pooya F.A at 14-Aug-12 10:11am
I did post it to my question. Hope you can help me please.
Christian Amado at 14-Aug-12 11:24am
ASP.NET, Winforms, WPF, Silverlight?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

May be you can investigate about RowEditEnded event.

Hope it helps.
Pooya F.A at 14-Aug-12 11:21am
Can you introduce more please.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Could u explain a little More and what u want to achive and paste u r whole grid design and u r procedure and the out put var

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

  Print Answers RSS
0 OriginalGriff 475
1 KrunalRohit 341
2 F-ES Sitecore 295
3 Afzaal Ahmad Zeeshan 230
4 CHill60 195
0 OriginalGriff 2,715
1 Maciej Los 1,900
2 KrunalRohit 1,797
3 CPallini 1,550
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 15 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100