Data won't save to database, C#

Posted 03 January 2013 - 08:48 AM

Hi, with your previus help, I managed to get most of the things sorted out. now there is a problem with my DataGridView. When I update row in DataGridView, it stays there until i close the program, so I suppose, changes are only made to loaded DataTable. I searched alot for the solution on the internet, but nothing worked.

Re: Data won't save to database, C#

Re: Data won't save to database, C#

Posted 03 January 2013 - 09:42 AM

1. I would remove line #11 since you are not using a stored procedure to update the database.
2. Make sure

void update (int)

is actually being called when the time comes (perhaps through an event?).
3. "When I update row in DataGridView, it stays there until i close the program, so I suppose, changes are only made to loaded DataTable." What do you mean by "stays there?"

That's a more correct and safe query. Whether or not that will make your code work, I don't know, because you could have connection problems, or other issues. But it's the correct way to use parameters in a query.

trichardson, on 03 January 2013 - 10:42 AM, said:

1. I would remove line #11 since you are not using a stored procedure to update the database.

One has nothing to do with the other. Parameters aren't just for stored procedures, they're the right way to do any query that needs input.