0

我有一个针对 IBM AS/400 数据库的选择查询的 asp 站点。如果应用程序查询仅使用表中的一个列名,它会返回数据,但是如果我在查询中有多个列名,则会引发'Attempted to read or write protected memory. This is often an indication that other memory is corrupt'错误消息。例如

SELECT ISDUI FROM PY.F55  <--returns data
or 
SELECT ISEMAL FROM PY.F55 <--returns data

SELECT ISDUI, ISEMAL FROM PY.F55 <--error out

这是.net代码:

public int runDB(string cmd, string sub, ref DataSet ds, string type)
{
    try
    {
        if (iDB2DataAdapter1 == null)
        {
            iDB2DataAdapter1 = new iDB2DataAdapter("", new iDB2Connection(G_AS400conn));
            iDB2DataAdapter1.SelectCommand.CommandTimeout = 0;
        }

        if (iDB2DataAdapter1.SelectCommand.Connection.State != ConnectionState.Open)
            iDB2DataAdapter1.SelectCommand.Connection.Open();

        iDB2DataAdapter1.SelectCommand.CommandText = @cmd;

        if (type == "S")
        {
            ds.Clear();
            rows = iDB2DataAdapter1.Fill(ds);
        }
        else
        {
            rows = iDB2DataAdapter1.SelectCommand.ExecuteNonQuery();
        }
        return rows;
    }
    catch(Exception ex)
    {
        //log error message
    }
}

有谁知道为什么会这样?

谢谢。

4

1 回答 1

0

请检查您使用的 .NET 数据提供程序库是否与您连接的系统具有相同的生产版本。

在尝试对 iSeries 执行简单查询时,我们遇到了与“AccessViolationException”异常相同的问题。通过将 IBM.Data.DB2.iSeries.dll 从 V5R3 升级到相同版本的目标系统:V5R4,问题得到解决。

于 2014-02-06T17:39:06.930 回答