Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The connection to the server was reset

Status
Not open for further replies.

Dabase

Programmer
Apr 2, 2004
122
0
0
PT
Hi,

I have an asp page that queries an SQL Server 2000 database, the user should then be able to save the resultset as an Excel file, using IE6

Code:
<%
'*********************************
'* Web Page:	 GenerateUsers.asp
'*********************************		
%>
<%
Response.expires = 0
Response.CacheControl = "no-cache"
Response.ContentType = "application/vnd.ms-excel"

Server.ScriptTimeout = 2000

Dim sMODE, arrUserRecord, iflgURecord

sMODE = Request("MODE")	

call openconn
call openComm
		
' Gets ID of new project

If sMODE="GLOBAL" Then
	sSQL = "select * from tblusers where u_d_id <> 2 and U_Active='1'"
ElseIf sMODE="AMERICAS" Then
	sSQL = "select * from tblusers where u_d_id <> 1 and U_Active='1'"
ElseIf sMODE="BOTH" Then
	sSQL = "select * from tblusers where u_d_id = 3 and U_Active='1'"
End If

comm.CommandText = sSQL
comm.CommandType = 1
set rs = comm.Execute()
			
	if not rs.eof then		
		arrUserRecord = rs.GetRows()
		iflgURecord = 1
	else
		iflgURecord = 0
	end if
			
set rs = nothing
call closeComm
Call CloseConn
%>

<title>My Admin Console</title>
<link href="stylesheets/my-admin.css" rel="stylesheet" type="text/css">
<body bottommargin="0" leftmargin="0" rightmargin="0" topmargin="0">
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <tr>
		<td align="left"><B>U_ID</B></td>
		<td align="left"><B>U_FullName</B></td>
		<td align="left"><B>U_Address1</B></td>
		<td align="left"><B>U_Address2</B></td>
		<td align="left"><B>U_City</B></td>
		<td align="left"><B>U_State</B></td>
		<td align="left"><B>U_PostCode</B></td>
		<td align="left"><B>U_C_ID</B></td>
		<td align="left"><B>U_Position</B></td>
		<td align="left"><B>U_Company</B></td>
		<td align="left"><B>U_Tel</B></td>
		<td align="left"><B>U_Email</B></td>
		<td align="left"><B>U_SystemID</B></td>
		<td align="left"><B>U_Password</B></td>
		<td align="left"><B>U_AL_ID</B></td>
		<td align="left"><B>U_D_ID</B></td>
		<td align="left"><B>U_MailingList</B></td>
		<td align="left"><B>U_Paying</B></td>
		<td align="left"><B>U_HTMLEmail</B></td>
		<td align="left"><B>U_PubBy</B></td>
		<td align="left"><B>U_PubDt</B></td>
		<td align="left"><B>U_ModBy</B></td>
		<td align="left"><B>U_ModDt</B></td>
		<td align="left"><B>U_Active</B></td>
  </tr>
  <%IF iflgURecord = 1 Then%>
	<%for i = 0 to ubound(arrUserRecord,2) %>
  <tr>
		<td align="left"><%=arrUserRecord(0,i)%></td>
		<td align="left"><%=arrUserRecord(1,i)%></td>
		<td align="left"><%=arrUserRecord(2,i)%></td>
		<td align="left"><%=arrUserRecord(3,i)%></td>
		<td align="left"><%=arrUserRecord(4,i)%></td>
		<td align="left"><%=arrUserRecord(5,i)%></td>
		<td align="left"><%=arrUserRecord(6,i)%></td>
		<td align="left"><%=arrUserRecord(7,i)%></td>
		<td align="left"><%=arrUserRecord(8,i)%></td>
		<td align="left"><%=arrUserRecord(9,i)%></td>
		<td align="left"><%=arrUserRecord(10,i)%></td>
		<td align="left"><%=arrUserRecord(11,i)%></td>
		<td align="left"><%=arrUserRecord(12,i)%></td>
		<td align="left"><%=arrUserRecord(13,i)%></td>
		<td align="left"><%=arrUserRecord(14,i)%></td>
		<td align="left"><%=arrUserRecord(15,i)%></td>
		<td align="left"><%=arrUserRecord(16,i)%></td>
		<td align="left"><%=arrUserRecord(17,i)%></td>
		<td align="left"><%=arrUserRecord(18,i)%></td>
		<td align="left"><%=arrUserRecord(19,i)%></td>
		<td align="left"><%=arrUserRecord(20,i)%></td>
		<td align="left"><%=arrUserRecord(21,i)%></td>
		<td align="left"><%=arrUserRecord(22,i)%></td>
		<td align="left"><%=arrUserRecord(23,i)%></td>
  </tr>
	<%Next%>
  <%End If%>
</table>
</body>

When the user clicks on the relevant link (for example GenerateUsers.asp?MODE=GLOBAL), a 'File Download' dialog is displayed prompting the user to either Open, Save or Cancel.

If the user clicks on Save, after a while (I have done various tests ranging from 30 - 60 seconds) the following
message is displayed:
The connection to the server was reset

If the user clicks on Open, after similar amount of time the The page cannot be displayed IE page is shown.

The file size is about 3.50MB for GLOBAL mode.

The above error is just occurring when MODE=GLOBAL.

The file sizes for AMERICAS and BOTH modes are 482KB and 35.5KB respectively.

Any help on this would be extremely appreciated.




Thanks
Dabase
 
from what i can see of this code, you have table-ised output, no problem HTML wise, but this page always seems to have a content-type of excel, yet no excel output, so if you were to try and take a html file, rename it an XLS, and open it in excel it prolly would burp on you as well.

there's many threads in this forum for ASP generated excel files, and also information on multiface pages, where the same page is a excel generator, an html page, and an in browser spreadsheet, etc, ( just examples )

i just think you need a few conditions above, and may want to look into the GetRows() method of ADODB, you can format CSV or excel data in pretty much 1 step with it.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never inside the 'loop' " - DreX 2005
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top