vb.net 填充数据表时“System.AccessViolationException:尝试读取或写入受保护的内存”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20884651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"System.AccessViolationException: Attempted to read or write protected memory" While Filling a DataTable
提问by George Filippakos
Using ASP.NET 4.51 and VS 2013 I am getting the following error when attempting to Fill a datatable using a stored procedure.
使用 ASP.NET 4.51 和 VS 2013 尝试使用存储过程填充数据表时出现以下错误。
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
回答by George Filippakos
I found the problem, the error was caused by the following:
我找到了问题,错误是由以下原因引起的:
The stored procedure had defined one of the parameters as bigint
存储过程已将参数之一定义为bigint
It should have been intas was defined in the database table schema.
它应该是在数据库表模式中定义的int。
I seems that passing an Integer value to a table adapter Stored Procedure expecting a Bigint causes an AccessViolationException error.
我似乎将整数值传递给需要 Bigint 的表适配器存储过程会导致 AccessViolationException 错误。
I hope this information helps somebody else.
我希望这些信息对其他人有帮助。

