Using ASP.NET 4.51 and VS 2013 I am getting the following error when attempting to Fill a datatable using a stored procedure.
System.AccessViolationException: Attempted to read or write protected memory
I have have traced the error to the following:
Using myDT As New DAL.mbr_MediaComments.usrsp_mbr_MediaComments_CommentorsDataTable
Using myTA As New DAL.mbr_MediaCommentsTableAdapters.usrsp_mbr_MediaComments_CommentorsTableAdapter
myTA.Fill(myDT, toMbrID, mediaID) <------System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Here is my stored procedure definition:
CREATE PROCEDURE [dbo].[usrsp_mbr_MediaComments_Commentors]
-- Add the parameters for the stored procedure here
@mbrID int = 0,
@mediaID bigint = 0
AS
BEGIN
//my query code
END
I found the problem, the error was caused by the following:
The stored procedure had defined one of the parameters as bigint
It should have been int as was defined in the database table schema.
I seems that passing an Integer value to a table adapter Stored Procedure expecting a Bigint causes an AccessViolationException error.
I hope this information helps somebody else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With