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!

Script time out.....but why ???

Status
Not open for further replies.

Eek

Technical User
Feb 4, 2001
34
0
0
CA
How come I always get a server script time out with the following code ? My Access database has only 10 records ?


<!--#include file="../../MyIncludes/Top_Survey.inc" -->

<%
if Session("LoggedIn") = "" then
Response.redirect "login.asp"
end if
%>


<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
dim IntNumber

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Survey.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblComments.* FROM tblComments;"

'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon

Response.Write ("<br>")
Response.Write ("<center>")
Response.Write ("<table border=1 id=table1 bordercolor=#C8DDCA align=center>")


Response.Write ("<tr>")

Response.Write ("<th width=80 align=center>")
Response.Write ("<B>")
Response.Write ("<font color=#2d5c3d size=+1 >")
Response.Write ("Number")
Response.Write ("</font>")
Response.Write ("</B>")
Response.Write ("</th>")

Response.Write ("<th width=25% align=center>")
Response.Write ("<font color=#2d5c3d size=+1 >")
Response.Write ("Password")
Response.Write ("</font>")
Response.Write ("</th>")

Response.Write ("<th width=25% align=center>")
Response.Write ("<font color=#2d5c3d size=+1 >")
Response.Write ("Answer")
Response.Write ("</font>")
Response.Write ("</th>")

Response.Write ("<th width=100 align=center>")
Response.Write ("&nbsp;")
Response.Write ("</th>")

Response.Write ("<th width=100 align=center>")
Response.Write ("&nbsp;")
Response.Write ("</th>")

Response.Write ("</tr>")





'Loop through the recordset
Do While not rsGuestbook.EOF

'Write the HTML to display the current record in the recordset

if IntNumber = "" then
IntNumber = 1
else
IntNumber = IntNumber + 1
end if


Response.Write ("<tr>")

Response.Write ("<td width=80 align=center>")
Response.Write ("<B>")
Response.Write (IntNumber)
Response.Write ("</B>")
Response.Write ("</td>")


Response.Write ("<td width=25% align=center>")
Response.Write (rsGuestbook("Name"))
Response.Write ("</td>")

Response.Write ("<td width=25% align=center>")
Response.Write (rsGuestbook("Comments"))
Response.Write ("</td>")


Response.Write ("<td width=100 align=center>")
Response.Write ("<a href=""Script_Delete.asp?ID=" & rsGuestbook("ID_no") & """>")
Response.Write ("Delete entry")
Response.Write ("</a>")
Response.Write ("</td>")


Response.Write ("<td width=100 align=center>")
Response.Write ("<a href=""update_form.asp?ID=" & rsGuestbook("ID_no") & """>")
Response.Write ("Update entry")
Response.Write ("</a>")
Response.Write ("</td>")


Response.Write ("</tr>")



'Move to the next record in the recordset
rsGuestbook.MoveNext

Loop

Response.Write ("</table>")
Response.Write ("</center>")

'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>

 
I'm new to asp myself and struggling with a similar issue but I think thisis the problem:

strSQL = "SELECT tblComments.* FROM tblComments;"

Try this instead
strSQL = "SELECT * FROM tblComments"


I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Problem is that you are using both dnsless and dns connections as you can clearly see from you own notes ...

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Survey.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

You should use only one of the two...

--
PG
 
I'm not sure how I see either of the posts above clearing it up, the code loks solid to me.

Try inserting some output lines every few lines to see if you can print out the status. Something like:
Response.Write "Script is executing whatever"
Response.Flush

When your inside the loop you could also print out the counter and maybe the id field (if you have one) so that you can watch and see if it is getting hung up there.

Also double-check that it isn'tgetting hung up inside your include file. I don't see anywhere for it to get hung up in the scirpt you posted but it is possible it is getting hung up in the include file if you don't have everything nicely sectioned off into functions.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
Witty Comment Here
 
speed suggestions :
first try tarwn's suggestions ...
also avoid using adodb.recordset where it's not really needed... you're not doing paging or anything of that nature that would need it in this code .. so just :

set RS = connection.execute(SQL)

then handle your RS the same way you are., less overhead on the server.

also check your DB, that table, say if it's got 100000 records in it, it will probably timeout try working with a pages recordset (revert to recordset object) or reducing the size of your data pull, you need to increase your server.scripttimeout = nSeconds (nseconds being how long you THINK it should take)



[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top