c# - SQL ODBC adapter out of memory exception -
i connecting , receiving data ibm's series as400 database, using odbc adapters , dataset.
i have odbc connection given below:
odbccommand cmd = new odbccommand(querystring, conn); // set active query odbcdataadapter rt = new odbcdataadapter(querystring, conn); // active data transfer dataset ds = new dataset(); // create dataset rt.selectcommand.commandtimeout = 180; // set command timeout rt.fill(ds); // transfer data var reader = ds.createdatareader(); // create reader reader.read(); // read while (reader.read()) { ... }
and strangely gives system.outofmemoryexception
on line rt.fill(ds);
if there 1billion rows 130 columns cause error?
how can avoid error , recieve data want?
if there 1billion rows 130 columns cause error?
that seems lot of data , cause error.
how can avoid error , recieve data want?
you should use datareader
directly, bypassing dataset
. if this, datareader
load 1 row of data, getting next row when call read
.
odbccommand cmd = new odbccommand(querystring, conn); // set active query conn.open(); // may not need if open var reader = cmd.executereader(); // create reader while (reader.read()) { ... } // process records, 1 @ time reader.close(); // close reader after use
more info:
odbcdatareader class @ msdn
Comments
Post a Comment