asp查询sql 执行很慢 求大神指点优化
1个回答
展开全部
<%
Function vTemp(StrA,StrB,StrC,StrD)
Set Mrs=Server.CreateObject("adodb.Recordset")
Mrs.open"Select Sum(TOTAL) From [V_LL] Whrer Year(TDATE)='"&StrA&"' And Month='"&StrB&"' And DEPT_CODE='"&StrC&"' and INV_PART_NUMBER='"&StrD&"'",adocon,3,1
if Mrs.eof then
Str="0"
else
Str=Mrs(0)
end if
vTemp=vTemp&Str
Response.Write vTemp
Mrs.close
set Mrs=nothing
End Function
Set rs=Server.CreateObject("adodb.Recordset")
rs.open"select DEPT_CODE,INV_PART_NUMBER from [V_L] order by DEPT_CODE",adocon,3,1
if rs.eof or rs.bof then
Response.Write "无内容"
else
Do While Not Rs.Eof
DEPT_CODE=rs("DEPT_CODE")
INV_PART_NUMBER=rs("INV_PART_NUMBER")
%>
<tr>
<td><%=vTemp("2016","2",DEPT_CODE,INV_PART_NUMBER)%></td>
<td><%=vTemp("2016","3",DEPT_CODE,INV_PART_NUMBER)%></td>
Function vTemp(StrA,StrB,StrC,StrD)
Set Mrs=Server.CreateObject("adodb.Recordset")
Mrs.open"Select Sum(TOTAL) From [V_LL] Whrer Year(TDATE)='"&StrA&"' And Month='"&StrB&"' And DEPT_CODE='"&StrC&"' and INV_PART_NUMBER='"&StrD&"'",adocon,3,1
if Mrs.eof then
Str="0"
else
Str=Mrs(0)
end if
vTemp=vTemp&Str
Response.Write vTemp
Mrs.close
set Mrs=nothing
End Function
Set rs=Server.CreateObject("adodb.Recordset")
rs.open"select DEPT_CODE,INV_PART_NUMBER from [V_L] order by DEPT_CODE",adocon,3,1
if rs.eof or rs.bof then
Response.Write "无内容"
else
Do While Not Rs.Eof
DEPT_CODE=rs("DEPT_CODE")
INV_PART_NUMBER=rs("INV_PART_NUMBER")
%>
<tr>
<td><%=vTemp("2016","2",DEPT_CODE,INV_PART_NUMBER)%></td>
<td><%=vTemp("2016","3",DEPT_CODE,INV_PART_NUMBER)%></td>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询