Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Time Consuming Script Problem

    Hello All,

    I have a script which runs for at least a minute before anything is given back in my call to it in AJAX httprequest.

    Can you help me find where I am missing the trick..

    here is the code ..

    Code:
    response.Clear()
    	response.Buffer=true
    	dim rs
    	set rs=Server.CreateObject("ADODB.RECORDSET")
    	call record (rs,"SELECT t.rscompany, CONCAT(t.PKCODE,' - ' , t.TYPE) FROM TBNAME t order by t.TYPE,t.PKCODE")
    	if not (rs.eof or rs.bof) then
    		%>
    		<select id='taskrsid' name='taskrsid' class='input_ radioselect'><option value=''>None</option><%
    		rs.movefirst
    		do while not (rs.eof)
    			%><option value='<%=rs(0)%>'><%=rs(1)%></option>
    			<%
    			response.Flush()
    			rs.movenext
    		loop
    		%></select><%
    		response.Flush()
    	end if
    	if rs.State = 1 then rs.Close
    	set rs = nothing
    The database is MySql 4.1.22-community-nt and my connection string has value like this
    "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=dbname; UID=dbuser;PASSWORD=dbpwd; OPTION=16387"

    I have checked with AJAX call it is working fine. The problem lies within the code.

    The Database table has PK column as varchar(255), with TYPE also varchar(255).

    Any help would be great!

    Mark

  • #2
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also I have 13678 Rows in the table.

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Without seeing what your "record" function is doing, it's a bit hard to say, but I'd do three things to it: take the buffering off, don't loop through a recordset directly, and stop jumping in and out of ASP:

    Code:
    dim rs, ary, optionValue, optionText
    
    set rs=Server.CreateObject("ADODB.RECORDSET")
    call record (rs,"SELECT t.rscompany, CONCAT(t.PKCODE,' - ' , t.TYPE) FROM TBNAME t order by t.TYPE,t.PKCODE")
    
    if not (rs.eof or rs.bof) then
    	
    	ary = rs.getRows()
    	rs.Close
    	set rs = nothing
    	
    	response.write("<select id='taskrsid' name='taskrsid' class='input_ radioselect'><option value=''>None</option>" & vbCrLf)
    	
    	for i = lBound(ary,2) to uBound(ary,2) 
    	
    		optionValue = ary(0,i)
    		optionText = ary(1,i)
    		
    		response.write("	<option value='")
    		response.write(optionValue)
    		response.write("'>")
    		response.write(optionText)
    		response.write("</option>" & vbCrLf)
    	
    	next
    	
    	response.write("</select>" & vbCrLf)
    	
    end if

  • #4
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Spudhead View Post
    Without seeing what your "record" function is doing, it's a bit hard to say, but I'd do three things to it: take the buffering off, don't loop through a recordset directly, and stop jumping in and out of ASP:

    Code:
    dim rs, ary, optionValue, optionText
    
    set rs=Server.CreateObject("ADODB.RECORDSET")
    call record (rs,"SELECT t.rscompany, CONCAT(t.PKCODE,' - ' , t.TYPE) FROM TBNAME t order by t.TYPE,t.PKCODE")
    
    if not (rs.eof or rs.bof) then
    	
    	ary = rs.getRows()
    	rs.Close
    	set rs = nothing
    	
    	response.write("<select id='taskrsid' name='taskrsid' class='input_ radioselect'><option value=''>None</option>" & vbCrLf)
    	
    	for i = lBound(ary,2) to uBound(ary,2) 
    	
    		optionValue = ary(0,i)
    		optionText = ary(1,i)
    		
    		response.write("	<option value='")
    		response.write(optionValue)
    		response.write("'>")
    		response.write(optionText)
    		response.write("</option>" & vbCrLf)
    	
    	next
    	
    	response.write("</select>" & vbCrLf)
    	
    end if
    This is good enough


  •  

    Posting Permissions

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