views:

183

answers:

1

I have an admin page in a Classic ASP web application that allows the admin user to run queries against the database (SQL Server 2000)

Whats really strange is that if the query you send has an error in it (an invalid table join, a column you've forgotten to group by etc) the BROWSER hangs (CPU usage goes to maximum) until the SERVER script timeout is exceeded and then spits out a timeout exceeded error (server and browser are on different machines, so not sure how this happens!) I have tried this in IE 8 and FF 3 with the same result.

If you run that same query (with errors) directly from SQL Enterprise Manager, it returns the real error immediately. Is this a security feature? Does anyone know how to turn it off? It even happens when the connection to the database is using 'sa' credentials so I dont think its a security setting :(

Dim oRS 
Set oRS = Server.CreateObject("ADODB.Recordset") 
oRS.ActiveConnection = sConnectionString 

// run the query - this is for the admin only so doesnt check for sql safe commands etc. 
oRS.Open Request.Form("txtSQL") 

If Not oRS.EOF Then 
    // list the field names from the recordset 
    For i = 0 to oRS.Fields.Count - 1 
        Response.Write oRS.Fields(i).name & " " 
    Next 
    // show the data for each record in the recordset 
    While Not oRS.EOF 
        For i = 0 to oRS.Fields.Count - 1 
       Response.Write oRS.Fields(i).value & " " 
        Next 
        Response.Write "<br />" 
        oRS.Movenext() 
    Wend 
End If 
+1  A: 

Try taking the core contents of the ASP (the bit that does the work) and stick it into a pure VBS script and run that from a cmd prompt via cscript (i.e., cscript bit_wot_does_stuff.vbs) and see how quickly that comes back. [Change Server.CreateObject to CreateObject and any Response.Write to WScript.Echo for it to work in a cmd environment].

Hopefully this will tell you whether the problem lies either in ASP/IIS or within some oddity with the ADO libs (although the code looks okay, but I haven't executed it :-) ).

Hopefully it'll give you something to then trace a bit further.

Chris J
Great idea, thanks. Interestingly, it returns the SQL error immediately! So suspicions confirmed, SQL Server doesnt return the syntax error on a SQL query coming from IIS - now the question is WHY and how to fix it... :)
Jimbo
It must be malfunctioning in a major way if its hanging the browser .. have you looked at a page load in IE whilst running http://www.fiddler2.com/fiddler2/ ?
Alex K.
sorry for the delayed response - stackoverflow decided i didnt need to be notified of your post :) with Fiddler I can see that the page load simply hangs until the timeout error is posted from IIS - i dont get WHY thats hanging the browser, but more to the point, why it takes SQL Server (and hence IIS) so long to return the timeout error AND why it doesnt return the REAL error!
Jimbo
@Jimbo - I can't answer that one. In my experience, errors tend to get bubbled straight up the stack with no delay. I'll try your ASP verbatim when I get a chance against a 2k database and see what I get. Might take a day or two though. Another thing to do as well (maybe): unless you know exactly which line in the ASP your execution is getting to, drop in a "Response.Write/Response.Flush" at each line, the Response.Flush mandatory so the Write is sent straight to the browser. Even if the browser doesn't display the data, looking at a Fiddler trace then should indicate how far the ASP got...
Chris J