Click here to Skip to main content
13,344,016 members (98,886 online)
Rate this:
Please Sign up or sign in to vote.
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 4:46am
Updated 15-Aug-12 9:43am
Wes Aday 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 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 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 14-Aug-12 10:11am
I did post it to my question. Hope you can help me please.
Christian Amado 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.180111.1 | Last Updated 15 Aug 2012
Copyright © CodeProject, 1999-2018
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