Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bug? relating to ImmediateDelete = false
Message
From
18/12/2008 18:51:25
 
 
To
18/12/2008 14:04:18
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01367909
Message ID:
01368710
Views:
9
>>>I am getting a "There is no row at position -1" application exception error under the following circumstances:
>>>
>>>I set ImmediateDelete = false in ABusinessObject because I want deletes to be applied to the backend tables only when I Save changes.
>>>
>>>I use a MaintenanceForm to select one record and immediately click the delete button to delete that single record. I confirm that I do want to delete the record.
>>>
>>>I then click the Save button (or the Close button and then confirm that I do want to save the changes) to apply the deletion to the backend table.
>>>
>>>Then I get the "There is no row at position -1" application exception error.
>>>
>>>This procedure is so simple to reproduce I am surprised that the problem has not been fixed already. I am using the most recent version.
>>
>>Does anyone have a solution to this BUG? Kevin?
>
>Hi Sam,
>
>I haven't had the opportunity to use or need this feature so can't help. I was wondering if you had stepped through the code to see why it wasn't working correctly? Is the data not getting posted back to the business object after the save so there is no rows?
>Tim

Hi Tim,

I have stepped through the code many times and I am amazed at how complicated the Mere Mortals Framework is. The problem actually occurs in the SaveDataSet(string tableName, int currentRow) method in the mmBusinessObject class. When I experience the problem, the "currentRow" parameter value passed into this method equals -1 and so the "this.DataRow = ds.Tables[tableName].Rows[currentRow];" causes the exception. I have copied the entire method below so you can see it quickly.

Remember, I use an mmMaintenanceForm to select a single record and then I delete it. Because I have set ImmediateDelete = false, that record is only marked deleted in the DataTable. That part works okay. That deleted record is the only record in the DataTable, but at this point the record still exists and is not marked deleted in the backend SQL Database Table. I then click Save expecting the deleted status of the record in the DataTable to be propagated to the backend SQL Database Table. That is when the exception occurs.
		/// <summary>
		/// (9) Saves the current DataSet's specified table to the default database
		/// </summary>
		/// <param name="tableName">Table Name</param>
		/// <returns>mmSaveDataResult enum value</returns>
		/// <param name="currentRow">Current row</param>
		public virtual mmSaveDataResult SaveDataSet(string tableName, int currentRow)
		{
			// Save the specified row number
			this.RowNum = currentRow;
			// Get the corresponding data row
			DataSet ds = this.GetCurrentDataSet();
			this.DataRow = ds.Tables[tableName].Rows[currentRow];
			// Save the data
			mmSaveDataResult result = this.SaveDataSet(ds, tableName);
			// Reset the row number to zero
			this.RowNum = 0;
			// Return the result
			return result;
		}
I think maybe I could find a solution if I could just understand why we are even using the "currentRow" value at all in this method. What is the reason for setting "this.RowNum = currentRow;" or "this.DataRow = ds.Tables[tableName].Rows[currentRow];"? Maybe it would all make sense if I just understood why.

Sam
Previous
Reply
Map
View

Click here to load this message in the networking platform