简体   繁体   中英

How to retrieve large data from Oracle database using C#?

I am trying to retrieve a large amount of data from an Oracle database in .NET. I am using a .NET DBDataReader which is working fine with small amount of data but when the data become medium or large it stops functioning and I have no idea why. How can i retrieve large amount of data?

You should try using ODP.NET . That is Oracle Data Provider written for .NET and it's much better optimized for communication with Oracle databases.

Microsoft deprecated Oracle Client (System.Data.OracleClient) ( http://blogs.msdn.com/adonet/archive/2009/06/15/system-data-oracleclient-update.aspx ) and advised to use 3rd hand tools.

EDITED:

Maby you should take a look at this similar question and answer: Big Performance Problems With Oracle DataReader in .Net

Ok, since you are expecting answers related to your question with very little information, answering these would help OTHERS to answer your question:

1- What is your data type in database

2- How are you trying to fetch the data (Some code would help a lot)

3- Are there any indexes, how big is the table and how complex is your query, have you tried optimizing it? Try writing your query.

...


Ok, here is what you can try and tell us if it changed anything...

static void DownloadBlob(OracleConnection myConnection)
{
  OracleCommand myCommand = new OracleCommand("SELECT * FROM table", myConnection);
  myConnection.Open();
  OracleDataReader myReader = myCommand.ExecuteReader(System.Data.CommandBehavior.Default);
  try
  {
    while (myReader.Read())
    {
      //Obtain OracleLob directly from OracleDataReader
      OracleLob myLob = myReader.GetOracleLob(myReader.GetOrdinal("Ordinal"));
      if (!myLob.IsNull)
      {
        // I hope it is BLOB :)
      }
    }
  }
  finally
  {
    myReader.Close();
    myConnection.Close();
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM