Export to Excel prob...

Results 1 to 3 of 3

Thread: Export to Excel prob...

  1. #1
    Lynn Maharet Guest

    Default Export to Excel prob...

    Hi all ...<BR> <BR>I have this button when pressed export the information to an excel file. depends on the month they selected..if they selected a month then only export the information based on the selected month else export all the information.<BR><BR>The problem is...it takes a lot of time it&#039s so slow sometimes tt it never generate the excel file at all....<BR>this happens when the user select a month. btw there are 39 fields in the database, maybe this cause the traffic.<BR>pls see code below... i really appreciate ur help...!<BR><BR><BR>If Not rs.EOF Then <BR> if session("mth") &#060;&#062; 0 then <BR> &#039means a mth is selected<BR> <BR> Do Until rs.EOF <BR> mm=mid(rs("Submit_date"),3,2)<BR> tempmm=CInt(mm) <BR> <BR> if session("mth") = tempmm then<BR> For i = 0 To rs.fields.Count-2<BR> xlWorksheet.Cells(iRow,i+1).Value = rs.fields(i+1) <BR> Next <BR> iRow = iRow + 1 <BR> rs.Movenext<BR> end if<BR> Loop<BR> else<BR> Do Until rs.eof <BR> &#039else export everything to excel<BR> For i = 0 To rs.fields.Count-2<BR> xlWorksheet.Cells(iRow,i+1).Value = rs.fields(i+1)<BR> Next<BR> iRow = iRow + 1 rs.MoveNext<BR> Loop<BR> End If<BR> end if<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Export to Excel prob...

    &nbsp;<BR>It appears to me that if this statement:<BR><BR> if session("mth") = tempmm then<BR><BR>evaluates to FALSE, then your routine would be stuck in an endless loop, because your recordset pointer would not be incremented. This would cause your script to timeout (after your server&#039s timeout value). See below for the change you probably need to make (switched the order of two lines):<BR><BR>If Not rs.EOF Then <BR>&nbsp;&nbsp;&nbsp;if session("mth") &#060;&#062; 0 then <BR>&nbsp;&nbsp;&#039means a mth is selected<BR><BR>&nbsp;&nbsp;Do Until rs.EOF <BR>&nbsp;&nbsp;&nbsp;mm=mid(rs("Submit_date"),3,2 )<BR>&nbsp;&nbsp;&nbsp;tempmm=CInt(mm) <BR><BR>&nbsp;&nbsp;&nbsp;if session("mth") = tempmm then<BR>&nbsp;&nbsp;&nbsp;&nbsp;For i = 0 To rs.fields.Count-2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xlWorksheet.Cel ls(iRow,i+1).Value = rs.fields(i+1) <BR>&nbsp;&nbsp;&nbsp;&nbsp;Next <BR>&nbsp;&nbsp;&nbsp;&nbsp;iRow = iRow + 1 <BR>&nbsp;&nbsp;&nbsp;end if<BR>&nbsp;&nbsp;&nbsp;rs.Movenext<BR>&nbsp;&nbsp ;Loop<BR>&nbsp;else<BR>&nbsp;&nbsp;Do Until rs.eof <BR>&nbsp;&nbsp;&nbsp;&#039else export everything to excel<BR>&nbsp;&nbsp;&nbsp;For i = 0 To rs.fields.Count-2<BR>&nbsp;&nbsp;&nbsp;&nbsp;xlWorksheet.Cells(iRo w,i+1).Value = &nbsp;&nbsp;&nbsp;&nbsp;rs.fields(i+1)<BR>&nbsp;&n bsp;&nbsp;Next<BR>&nbsp;&nbsp;&nbsp;iRow = iRow + 1 rs.MoveNext<BR>&nbsp;&nbsp;Loop<BR>&nbsp;End If<BR>end if<BR><BR>

  3. #3
    Lynn Maharet Guest

    Default Same error persists

    Hi JD..<BR><BR>I&#039ve changed the codes but the same error persists saying script time out...But i admit the change u told me is correct, i have to rs.movenext if session("mth") &#060;&#062; tempmm ...thanks ya..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts