Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error during Cancel of newly added record
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Error during Cancel of newly added record
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01065305
Message ID:
01065305
Views:
63
Im using version 1.4.2

I create a subclass of mmBusinessForm.
I register a primary bizobj oBizObj
I drop one control on the form and bind it to a field
In the load of the form, I add a new row :

oBizObj.NewRow();

I run the app, I change the value of the bound control, and then close the form.

I am prompted as to whether I want to save, and I choose No, which calls the Cancel() of the form. The cancel is performed, leaving no records in the dataset, but I get the following error:

No value at index -1.

It fails in the following method of mmBusinessForm:

public virtual void Cancel(mmBusinessObject bizObj, string tableName)

It fails on the following line:
bizObj.DataRow = (this.GetCurrentRow(bizObj.GetCurrentDataSet(), tableName)).Row;
The error appears to be that because the table is empty, there are no rows to bind to.

Anyone have a work around for this? Is there a property I'm missing that prevents this error?


Here's the stack trace
   at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)
   at System.Windows.Forms.CurrencyManager.get_Current()
   at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.GetCurrentRow(DataSet ds, String tableName)
   at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.Cancel(mmBusinessObject bizObj, String tableName)
   at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.Cancel(mmBusinessObject bizObj)
   at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.AskSaveChanges(mmBaseBusinessObject bizObj)
   at DMS.TestCancel.AskSaveChanges(mmBaseBusinessObject bizObj) in d:\documents and settings\rick.hodder\my documents\visual studio projects\dms\testcancel.cs:line 99
   at OakLeaf.MM.Main.Windows.Forms.mmBusinessBaseForm.AskSaveChanges()
   at DMS.TestCancel.AskSaveChanges() in d:\documents and settings\rick.hodder\my documents\visual studio projects\dms\testcancel.cs:line 94
   at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.mmBaseForm_Closing(Object sender, CancelEventArgs e)
   at System.Windows.Forms.Form.OnClosing(CancelEventArgs e)
   at DMS.TestCancel.OnClosing(CancelEventArgs e) in d:\documents and settings\rick.hodder\my documents\visual studio projects\dms\testcancel.cs:line 105
   at System.Windows.Forms.Form.WmClose(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DefMDIChildProc(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.Form.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmSysCommand(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DefMDIChildProc(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.Form.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmNcButtonDown(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.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.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at DMS.Main.AppMainEntry.Main() in D:\Documents and Settings\rick.hodder\My Documents\Visual Studio Projects\DMS\Main.cs:line 45
Rick Hodder
MCP Visual Foxpro
C#, VB.NET Developer
Independent Consultant
www.RickHodder.com
MyBlog
Next
Reply
Map
View

Click here to load this message in the networking platform