问题描述
大家好,
我正在使用C#4.0创建一个应用程序,该应用程序确实从Oracle数据库的所有表中进行选择.对于大多数表,代码执行正常.但是,我收到一条错误消息:未处理AccessViolationException:尝试读取或写入受保护的内存.这通常表明其他内存已损坏."在OdbcDataReader.HasRows属性中.我添加了try catch块,但是应用程序仍然停止并且没有进入catch部分.
这是一段代码:
Hi all,
I am creating an application using C# 4.0 that do select from all tables in Oracle database. For most tables, the code performs okay. However, I got an error saying "AccessViolationException was unhandled: Attempted to read or write protected memory. This is often an indication that other memory is corrupt." in the OdbcDataReader.HasRows property. I added try catch block, but the application still stops and not entering the catch section.
Here is the piece of code:
public void Execute(string query, ref List<String> columnNames, ref Dictionary<int, String> rows)
{
OdbcCommand odbcCommand;
OdbcDataReader odbcDataReader;
try
{
odbcCommand = _odbcConnection.CreateCommand();
odbcCommand.CommandText = query;
// right after executing this line of code, the OdbcDataReader.HasRows threw an exception
odbcDataReader = odbcCommand.ExecuteReader();
// ... other lines of code
注意:当我使用TOAD for Oracle进行查询时,该表没有任何行.
任何想法如何解决此问题?
Note: when I do query using TOAD for Oracle, the table does not have any rows.
Any ideas how to solve this problem?
推荐答案
这篇关于OdbcDataReader引发AccessViolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!