Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8400519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:34:41+00:00 2026-06-09T21:34:41+00:00

I can’t update when I change some field in my table. Database ==> mysql

  • 0

I can’t update when I change some field in my table.

  • Database ==> mysql
  • .net framework ==> 4.0
  • platform==> wpf app

let me explain step by step

my aim is updating item which already exists in table.

   public bool SaveToVideoInfo(List<tblvideoinfo> vList,sbyte profilID)
    {
                     foreach (tblvideoinfo _videoinfo in vList)
            {

                try
                {

                ent.AddTotblvideoinfo(_videoinfo);
                ent.AddTotblprocess(CreateProcess(profilID,_videoinfo.VideoID));
                ent.SaveChanges();

                }
                catch (UpdateException )
                {

                   return UpdateToVideoInfo(_videoinfo);
                }            
        }

            return false;                     
    }

if already item exists in table, I’m catching this exception and calling my update function

    public bool UpdateToVideoInfo(tblvideoinfo vInfo)
    {

        var updatingItem = (from a in ent.tblvideoinfo
                  where a.VideoID == vInfo.VideoID
                  select a).First();

        updatingItem.SearchKeywords = vInfo.SearchKeywords;
        updatingItem.SearchTimeStamp = DateTime.Now;

        return ent.SaveChanges() > 0;

    }

because if it exists in table, I want to change some field as I wrote above. Everything is fine until running ent.SaveChanges()

I checked updatingItem has been changed which I set properties (SearchKeywords ,SearchTimeStamp )

But this error occurs

error occurred while updating the entries. See the inner exception for details

here are details

 at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
   at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
   at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
   at System.Data.Objects.ObjectContext.SaveChanges()
   at MyDbHelper.DBHelper.UpdateToVideoInfo(tblvideoinfo vInfo)
   at MyDbHelper.DBHelper.SaveToVideoInfo(List`1 vList, SByte profilID)
   at youtube.MainWindow.p_Drop_Event(Object sender, Object to) in C:\Users\xxxxxx....\...\MainWindow.xaml.cs:line 1125
   at youtube.product.UserControl_MouseUp(Object sender, MouseButtonEventArgs e) in C:\Users\xxxxxx....\...\product.xaml.cs:line 239
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at youtube.App.Main() in C:\Users\xxxxxx....\...\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

here is detail of updatingItem

here is detail of updatingItem

means,

    updatingItem.SearchKeywords = vInfo.SearchKeywords;
    updatingItem.SearchTimeStamp = DateTime.Now;

these codes are work.

by the meantime, VideoID is unique in my table then I cant add item which has same VideoID. But I want to update it. I think updating issue comes from here.

I don’t want to use sql commands.

I just want to update two fields of the table …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:34:42+00:00Added an answer on June 9, 2026 at 9:34 pm

    My guess is that when you call SaveChanges again on the same context it is trying to insert repeat the insert operation and fails again.

    Calling ent.AcceptAllChanges() in the beginning of the catch block may work.

    Maybe disposing the context and creating another one to use in the update function would be your easiest option. Otherwise, you will need to change the ObjectStateEntry.State to Unchanged for the two entities (videoinfo, process) you try to insert.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone let me know how can we change the value of kendo combobox
Can I change the field public virtual ClassOne ClassOne { get; set; } to
can you recommend some good ASP.NET tutorials or a good book? Should I jump
Can a LINQ enabled app run on a machine that only has the .NET
Can I order my users in the database, so I don't have to say
Can we change the default action of the edit selected row button? Here is
Can anybody shed some light on getDay() in Javascript please. Here datepicker is textbox
Can I register a .Net COM class with the SingleUse -flag? The reason I
Can we change the color of the divider? Apple documentations says, that we can
Can someone tell me how does the imdb app manage to play trailers on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.