Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Respected sir

I am trying to update data into database using c# (entity framework).I am not getting any error in the code,instead record successfully updated message appears.But I don't find any changes in Database table.I am struggling for two hours,but nothing positive came up.



Thanks in advance
Posted
Comments
[no name] 23-Jul-13 6:00am    
Based on the zero amount of information that you have given us, the only thing I can say is, debug your code and find out why.
Alexander Dymshyts 23-Jul-13 6:07am    
can you provide your code?
Basmeh Awad 23-Jul-13 8:21am    
show your code..

1 solution

C#
//For Saving and updating if you are using linq to entities

using (CustomerEntities customerDataContext= new CustomerEntities())
{
    Customer customer = (from c in customerDataContext.Customers
             where c.Name == "customer name"
             selext c).First();

   if(customer !=null)
   {
     c.Name = "New Customer Name";
   }

    customerDataContext.Customers.SaveChanges();
}
 
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