首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

SubmitChanges未将对象引用设立到对象的实例

2012-12-30 
SubmitChanges未将对象引用设置到对象的实例给位高手OutDetails outObj new OutDetails()outObj.BillNo

SubmitChanges未将对象引用设置到对象的实例
给位高手
            OutDetails outObj = new OutDetails();
            outObj.BillNo = obj.BillNo;
            outObj.DetailCount = obj.DetailCount;
            outObj.DetailNo = obj.DetailNo;
            outObj.MaterialName = obj.MaterialName;
            ctx.OutDetails.InsertOnSubmit(obj);
            ctx.SubmitChanges();
然后提交的时候报,未将对象引用设置到对象的实例。
请问是什么错误啊?

   在 System.Data.Linq.ChangeTracker.StandardChangeTracker.IsFastTracked(Object obj)
   在 System.Data.Linq.ChangeTracker.StandardChangeTracker.GetTrackedObject(Object obj)
   在 System.Data.Linq.ChangeProcessor.TrackUntrackedObjects(MetaType type, Object item, Dictionary`2 visited)
   在 System.Data.Linq.ChangeProcessor.TrackUntrackedObjects(MetaType type, Object item, Dictionary`2 visited)
   在 System.Data.Linq.ChangeProcessor.TrackUntrackedObjects()
   在 System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
   在 System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
   在 System.Data.Linq.DataContext.SubmitChanges()
   在 LinqBLL.OutDetailsObject.Save(OutDetails obj) 位置 D:\Learnning\CS\LinqDemo\LinqDemo\OutDetailsObject.cs:行号 43
   在 LinqBLL.OutBillObject.Save(OutBillObject obj) 位置 D:\Learnning\CS\LinqDemo\LinqDemo\OutBillObject.cs:行号 60
   在 Demo.Add.button1_Click(Object sender, EventArgs e)
   在 System.Windows.Forms.Control.OnClick(EventArgs e)
   在 System.Windows.Forms.Button.OnClick(EventArgs e)
   在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
   在 System.Windows.Forms.Button.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.RunDialog(Form form)
   在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)


   在 System.Windows.Forms.Form.ShowDialog()
   在 Demo.Main.button2_Click(Object sender, EventArgs e)
   在 System.Windows.Forms.Control.OnClick(EventArgs e)
   在 System.Windows.Forms.Button.OnClick(EventArgs e)
   在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
   在 System.Windows.Forms.Button.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.Run(Form mainForm)
   在 Demo.Program.Main()
   在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   在 System.Threading.ThreadHelper.ThreadStart()

[解决办法]
ctx.OutDetails.InsertOnSubmit(obj);
===========
ctx.OutDetails.InsertOnSubmit(outObj);

具体情况,单步调试一下,看出错在哪一行

热点排行