update records using linq to sql [Resolved]

Posted by Jopito under ASP.NET on 11/23/2013 | Points: 10 | Views : 1660 | Status : [Member] | Replies : 10
I have a method which should update records in a database,the problem is tha ut shows records updated in the radgrid but nothing changes on close.I cannot figure out where am wrong.Can someone give me some directives please?Thanks

Mark as answer if satisfied


Responses

Posted by: Jopito on: 11/25/2013 [Member] Starter | Points: 25

Up
0
Down

Resolved
userToUpdate.CustomerName = CustomerName;
userToUpdate.username = username;
userToUpdate.telephone = telephone;
userToUpdate.email = email;
userToUpdate.course = course;
db.SubmitChanges(ConflictMode.FailOnFirstConflict);
return userToUpdate;

This is my method to update and its not working

Mark as answer if satisfied

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 11/25/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
Dot use the Int.parse.
Try to use the
Convert.ToInt64()

and it will solve you error.

Happy Coding,
If it helps you or directs U towards the solution, MARK IT AS ANSWER

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 11/23/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Can u please paste your code, so that it would be more understood.

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 11/24/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
make sure that you have context.SubmitChanges() call

Post us back the UPDATE functionality code

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 11/24/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Plese refer below links:
http://www.codeproject.com/Articles/215712/LINQ-to-SQL-Basic-Concepts-and-Features
http://www.youtube.com/watch?v=8ql8SWYRzOk
http://www.progtalk.com/viewarticle.aspx?articleid=68

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 11/24/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Please also refer:-
http://www.dotnetfunda.com/articles/show/39/working-with-linq-to-sql-classes-and-linqdatasource-controls
http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/using-linq-to-sql-class/

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 11/24/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
See the below links:-

http://msdn.microsoft.com/en-us/library/bb399339(v=vs.110).aspx
http://stackoverflow.com/questions/15338708/how-to-update-a-database-using-linq-to-sql

Happy Coding,
If it helps you or directs U towards the solution, MARK IT AS ANSWER

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 11/25/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
May be try this?

userToUpdate.CustomerName = CustomerName;
userToUpdate.username = username;
userToUpdate.telephone = telephone;
userToUpdate.email = email;
userToUpdate.course = course;
db.SubmitChanges();
return userToUpdate;


ConflictMode.FailOnFirstConflict : Specifies that attempts to update the database should stop immediately when the first concurrency conflict error is detected.
Might be you are getting any exception while update....

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jopito on: 11/25/2013 [Member] Starter | Points: 25

Up
0
Down
It throw an exception Value was either too large or too small for an Int32 in line 114.
Have used datatype bigint in the database and on the code have converted it to long using Int.parse
Line 112: {
Line 113:
Line 114: throw;
Line 115: }
Line 116: }

Mark as answer if satisfied

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jopito on: 11/25/2013 [Member] Starter | Points: 25

Up
0
Down
Have used the debugger and noticed that it does not pick the newly entered info in the textboxes,i hope you can now give me an option at this stage?Thank you

Mark as answer if satisfied

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response