.net - Exception coming when exporting data to excel -
i getting following error while exporting data excel sheet
error: message : exception of type 'system.web.httpunhandledexception' thrown. error description : system.web.httpunhandledexception: exception of type 'system.web.httpunhandledexception' thrown. ---> system.data.sqlclient.sqlexception: timeout expired. timeout period elapsed prior completion of operation or server not responding.
anybody suggest me have do.
code: griddata.datasource = getdata() griddata.databind() response.clear() response.addheader("content-disposition", "attachment;filename=completiondatesreport.xls") response.charset = "" response.cache.setcacheability(httpcacheability.nocache) response.contenttype = "application/vnd.xls" dim stringwrite stringwriter = new stringwriter() dim htmlwrite htmltextwriter = new htmltextwriter(stringwrite) griddata.rendercontrol(htmlwrite) response.write(stringwrite.tostring()) response.end()
without code can guess, there big clue in sqlexception: timeout expired
- suggests query taking long. can increase timeout on command (but try keep sane...) via sqlcommand.commandtimeout
, writing query more efficient, or not pulling data in 1 query, preferable.
Comments
Post a Comment