c# - How to minimise OleDbDataAdapter time to fetch data from remote database -
my windows form application contains oledbdataadapter, consuming longer time fetch data remote db. not able retrieve/hold table data 5000 rows(application gets struck). here code.
environments = configurationmanager.getsection("environment") namevaluecollection; string strconnstring = environments[envs]; conn = new oledbconnection(strconnstring); conn.open(); oledbdataadapter objda = new oledbdataadapter("select * tblabc", conn); dataset ds1 = new dataset(); objda.fill(ds1); datagridview1.datasource = ds1.tables[0];
environment section configured in app.config file :
<configuration> <configsections> <section name ="environment" type="system.configuration.namevaluesectionhandler" /> </configsections> <environment> <add key ="cit" value ="password=pwd123;user id=abc123;data source=db1;persist security info=true;provider=msdaora"/> <add key ="sit" value ="password=pwd234;user id=abc234;data source=db2;persist security info=true;provider=msdaora"/> <add key ="uat" value ="password=pwd345;user id=abc345;data source=db3;persist security info=true;provider=msdaora"/> </environment> </configuration>
it greatful if suggest better approach/mechanism code.
did try work threads. create sub function somewhere in program below
public void datapullingthread(){ try{ //your connection code goes here below// environments = configurationmanager.getsection("environment") namevaluecollection; string strconnstring = environments[envs]; conn = new oledbconnection(strconnstring); conn.open(); oledbdataadapter objda = new oledbdataadapter("select * tblabc", conn); dataset ds1 = new dataset(); objda.fill(ds1); datagridview1.datasource = ds1.tables[0]; conn.close(); } catch (exception e){ } } //call thread desired location in program/// using system.threading; thread thread = new thread (new threadstart(datapullingthread)); thread.start; //your application continuously run; however, data appear when ever thread auto kills itself. can boost speed if create more 1 thread. means each thread selecting different rows of database, hope information you//
Comments
Post a Comment