How to read large excel files containing more that 200,000 rows and load that data in datatable in C# -


i working on reading data excel , loading in datatable. problem is giving systemoutofmemoryexception while loading large excel files. colomns in excel not fixed can't load data in sql table. need manipulation on data loading in datatable. can suggest me how resolve issue?

i doing

 oledbconnection conn = new oledbconnection();                 oledbcommand cmd = new oledbcommand();                 oledbdataadapter da = new oledbdataadapter();                 conn = new oledbconnection(getoledbconnectionstring(strfiletype, strnewpath));                 if (conn.state == connectionstate.closed) conn.open();                     string query = null;                 datatable dt = new datatable();                                query = "select  * [" + spreadsheetname + "]";                                 cmd.connection = conn;                 cmd.commandtext = query;                 da.selectcommand = cmd;                 da.fill(dt);                 da.dispose();                 conn.close();                 conn.dispose(); 

your problem not enough memory - application runs 32 bit app , stuff load overloading it.

make 64 bit application (in settings under executable project) - , make sure have physical memory adequate modern machine (8+gb).


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -