SQL Server Studioで13000行を超える1秒かかるビューは、約2380行後にこのコードを実行しているASPページでタイムアウトになります。
これを行うためのより良い方法はありますか?運が悪かったので6ヶ月間探していました。
Server.ScriptTimeout=200
dim updateNBK
updateNBK = UCase(request.QueryString("SelTABLE"))
dim allstring
allstring = UCase(Request.QueryString("SelTABLE")) & " " & UCase(Request.QueryString("SelNBK"))
allstring = LCase(allstring)
dim checkforinject
If(InStr(allstring, "'")<>0)then
checkforinject = true
Elseif(InStr(allstring, "--")<>0)then
checkforinject = true
End If
If (checkforinject = true) then
Response.Write("<b>Injection Detected</b><br/> You may not enter the following characters: ' or --")
Elseif (checkforinject = false) then
dim strSQL
if(Request.QueryString("submitbutton") = "Download") then
strSQL = "select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '" & UCase(request.QueryString("SelTABLE")) & "'"
On Error Resume Next
set arn = cnt.execute(strSQL)
dim datastr
dim datahead
datahead = "<table class='bluetable'><thead><tr><td colspan='30'>" & UCase(request.QueryString("SelTABLE")) & " contents</td></tr></thead>"
dim columns
colums = 0
datastr = datastr & "<tbody class='datasheet'><tr class='selectblue'>"
if not arn.EOF then
arn.movefirst
do
On Error Resume Next
datastr = datastr & "<td>" & arn(0) & "</td>"
columns = columns + 1
arn.movenext
loop until arn.EOF
end if
datastr = datastr & "</tr>"
strSQL = "Select * from " & UCase(request.QueryString("SelTABLE"))
if(UCase(Request.QueryString("SelNBK")) <> "") then
strSQL = strSQL & " where SubmitterNBK = '" & UCase(Request.QueryString("SelNBK")) & "'"
end if
set arn = cnt.execute("Select TimestampColumnName from FormsInfo where FormOutput='" & UCase(request.QueryString("SelTABLE")) & "'")
strSQL = strSQL & " ORDER BY " & arn(0) & " desc;"
Response.Write "Test1"
On Error Resume Next
set arn = cnt.execute(strSQL)
dim counter
counter = 0
if not arn.EOF then
arn.movefirst
Response.Write "Test2"
dim cellnum
do
datastr = datastr & "<tr>"
On Error Resume Next
cellnum = 0
'datastr = datastr & "<td>" & arn.value.toString() & "</td>"
do
datastr = datastr & "<td>" & arn(cellnum) & "</td>"
cellnum = cellnum + 1
loop while cellnum < columns
arn.movenext
'Response.Write "TestLoop"
Response.Write "<br/>Loop ran " & counter & " times."
counter = counter + 1
datastr = datastr & "</tr>"
loop until arn.EOF
Response.Write "<br/>Loop ended."
end if
datahead = "<table class='bluetable'>"
Response.Clear
Response.ContentType = "application/vnd.ms-excel" ' arbitrary
Response.AddHeader "Content-Disposition","attachment; filename=" & UCase(request.QueryString("SelTABLE")) & ".xls"
Set adoStream = CreateObject("ADODB.Connection")
adoStream.Open()
adoStream.Type = 2
Response.Write datahead & datastr
Response.Flush
adoStream.Close
Set adoStream = Nothing
Response.End