Always get exception when trying to Fill data to DataTable

Posted by Sambath on Stack Overflow See other posts from Stack Overflow or by Sambath
Published on 2009-03-03T03:30:05Z Indexed on 2010/04/11 1:03 UTC
Read the original article Hit count: 400

Filed under:
|

The code below is just a test to connect to an Oracle database and fill data to a DataTable. After executing the statement da.Fill(dt);, I always get the exception "Exception of type 'System.OutOfMemoryException' was thrown.". Has anyone met this kind of error? My project is running on VS 2005, and my Oracle database version is 11g. My computer is using Windows Vista. If I copy this code to run on Windows XP, it works fine.

Thank you.

using System.Data;
using Oracle.DataAccess.Client;

...

string cnString = "data source=net_service_name; user id=username; password=xxx;";
OracleDataAdapter da = new OracleDataAdapter("select 1 from dual", cnString);

try
{
   DataTable dt = new DataTable();
   da.Fill(dt);  // Got error here
   Console.Write(dt.Rows.Count.ToString());

}
catch (Exception e)
{
   Console.Write(e.Message); // Exception of type 'System.OutOfMemoryException' was thrown.
}

Update

I have no idea what happens to my computer. I just reinstall Oracle 11g, and then my code works normally.

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about c#