DataLayer exception has me stumped


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.7K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm getting the following exception when I save a new record. The record is saved fine, but apparently there is an error when the data layer goes to refresh the data. What might be causing this?



DETAILS

------------

DataLayerSavingException

Invalid attempt to read when no data is present.

InvalidOperationException

Invalid attempt to read when no data is present.



Source : MicroFour StrataFrame Business



Stack Trace:

at System.Data.SqlClient.SqlDataReader.GetValue(Int32 i)

at System.Data.SqlClient.SqlDataReader.get_Item(String name)

at MicroFour.StrataFrame.Data.SqlDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)

at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler)

at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)

at MicroFour.StrataFrame.Business.BusinessLayer.Save(Boolean Transactional, String TransactionKey)

at MicroFour.StrataFrame.Business.BusinessLayer.Save()

at FOXSystems.RAMS.UI.Navigation.ListBONavBase.SaveData() in E:\FoxSystems\RAMS\trunk\RAMS.NET\RamsUI\Navigation\ListBONavBase.vb:line 418

at FOXSystems.RAMS.UI.Navigation.ListBONavManager._saveControl_Click(Object sender, EventArgs e) in E:\FoxSystems\RAMS\trunk\RAMS.NET\RamsUI\Navigation\ListBONavManager.vb:line 221

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(Int32 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 MicroFour.StrataFrame.Application.StrataFrameApplication.RunApplication()

StrataFrame Team
S
StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Was it an INSERT, UPDATE, or DELETE?  The only one that uses a DbDataReader (I think) is the INSERT, which it uses to retrieve the PrimaryKey that was assigned by the IDENTITY field.  So, it could be the case that there was not data returned... or that there is no IDENTITY on the field, or something like that.  Could you confirm whether the record is an INSERT, and also, it would help to see the last command that it tried to execute (by turning on DebugMode on the SqlDataSourceItem).
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.7K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I figured it out. It was an insert, the PK was an identity, but...



I am doing some fancy auditing on this table, that includes an Instead Of Trigger. It does a bunch of updates to other tables, so the SCOPE_IDENTITY() function doesn't work. I'm doing a conversion from an Access front end to .NET and was hoping to avoid this issue a while longer Ermm



Thanks for getting me thinking though! BigGrin
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search