sql-server - "System.AccessViolationException: Attempted to read or write protected memory"填充数据表时

标签 sql-server vb.net stored-procedures ado.net

使用 ASP.NET 4.51 和 VS 2013 尝试使用存储过程填充数据表时出现以下错误。

System.AccessViolationException: Attempted to read or write protected memory

我已将错误追溯到以下几点:
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.

这是我的存储过程定义:
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

最佳答案

我找到了问题,错误是由以下原因引起的:

存储过程已将参数之一定义为 bigint

应该是 国际正如在数据库表模式中定义的那样。

我似乎将整数值传递给需要 Bigint 的表适配器存储过程会导致 AccessViolationException 错误。

我希望这些信息对其他人有帮助。

关于sql-server - "System.AccessViolationException: Attempted to read or write protected memory"填充数据表时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20884651/

相关文章:

c# - 通过 VB.NET 和 C# 中的 Ref 参数

mysql - 对另一个表中的所有 ID 运行 MySql 查询

sql-server - 如何在 SQL Server 2012 中使用 GROUP BY

mysql - 通过映射表选择值。

vb.net - VB.NET 可空语法的历史

c# - Asp.net 中的异步 Web 服务

SQL Server Formatmessage 函数无法使用过程中的变量

c# - 如何测试C#代码与Sql Server存储过程的同步

使用另一个表的结果进行 SQL 更新

SQL Server linux转发