Updating table from C#

dmauldindmauldin Member Posts: 37
edited 2010-10-23 in NAV Three Tier
I created a C# form to update a table in NAV. I have it connecting through web services. The table is a custom table of ours. It's much like the customer table. I create the record then update the Name field calling service.Update. But I get an odd error. Below is the detail. It looks like it errors out on a date field but I'm not doing anything with a date field. The table is updating a date field when the record is added, could that be it? The record id created and the name is in the record.

System.InvalidOperationException was unhandled
Message=There is an error in XML document (1, 2160).
Source=System.Xml
StackTrace:
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at LeadTest.LeadWebReference.Lead_Service.Update(Lead& Lead) in D:\David\Programming\projects\Web Services\VS2010\LeadTest\LeadTest\Web References\LeadWebReference\Reference.cs:line 276
at LeadTest.Form1.btnSubmit_Click(Object sender, EventArgs e) in D:\David\Programming\projects\Web Services\VS2010\LeadTest\LeadTest\Form1.cs:line 32
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at LeadTest.Program.Main() in D:\David\Programming\projects\Web Services\VS2010\LeadTest\LeadTest\Program.cs:line 20
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.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.FormatException
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Xml.XmlConvert.ToInt32(String s)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLead_Service.Read9_Lead_Duplicates_Line(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLead_Service.Read10_Lead(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLead_Service.Read13_Update_Result()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
InnerException:

Comments

  • ara3nara3n Member Posts: 9,256
    I suggest to use the debugging functionality of Service tier to see where it is erroring out.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • dmauldindmauldin Member Posts: 37
    When I start running my C# code, will it debug page in NAV?
  • ara3nara3n Member Posts: 9,256
    There is a blog on how to start NAV service tier in debug mod. Basically you have to change custome settings.xml to enable debugging. This will put all the NAV C# code in a folder and then you can open the CU/Page you have published and attach NAV service tier.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • kinekine Member Posts: 12,562
    I think that key info is that the problem is in "StringToNumber" method. It looks like you are using wrong data i nconnection with number field...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.