我正在运行从经典asp网页到Microsoft Access 2000数据库表的查询,以返回名称查询并执行计算。该数据库已运行多年,过去的所有查询都已成功。过去几个月突然显示一些名称和计算,出现以下错误:错误80020009.在显示的查询的底部,显示一个人的姓名,但不显示计算字段;它是空白的。计算领域在经典asp中使用计数选项,并且是Microsoft Access中的文本数据类型。由于错误信息直到最近几个月才出现,这很奇怪。我能够在Microsoft Access表(在我的开发环境中)中找到导致特定月份错误的记录,但我不想删除生产环境中的记录。如果我在Microsoft Access中运行SQL查询,表中给定月份中的所有记录(问题apepars)都没有问题,并且不会出现错误。我已导出并导入Access表,但仍会出现8002009错误。
有没有人遇到过这样的问题?这听起来像是经典的asp编码问题,还是Microsoft Access 2000数据库表本身的问题。
感谢您的帮助。
答案 0 :(得分:0)
<div>
<br />
<h1 class="main">CO Report</h1>
<hr class="main">
<blockquote>
<form method="POST" action="os.asp" name="form2">
<p>Month to Query:
<select size="1" name="ddmonth">
<%
dim i
for i = 1 to 12
if i = month(date) then
%> <option selected value="<%=i%>"><%=monthname(i)%></option>
<% 'select the current month
else
%> <option value="<%=i%>"><%=monthname(i)%></option>
<%
end if
next
%></select> <select size="1" name="ddyear">
<%
dim intyear
for intyear = 2001 to year(date)
response.write ("<option selected>" & intyear & "</option>")
next
%></select> <input type="submit" value="Query CS" name="btnQUERY"></p>
</form>
<hr /><br />
<%
if request.form("btnQUERY") <> "" then
'display the table based on the selected month and year
'setup query
strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\store\stats\data\pros.mdb"
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open strConn
'open the recordset
Set rstData = Server.CreateObject("ADODB.Recordset")
rstDATA.open "SELECT * FROM [tv] ORDER BY toc", cnn, adOpenKeyset
%>
<table border="1" width="100%" id="AutoNumber2" height="18" cellspacing="1">
<caption>CU-Out Results for <%=monthname(Request.form("ddmonth"))%>, <%=request.form("ddyear")%></caption>
<tr>
<th>Officer's Name</th>
<th>Minutes Achieved - CUW</th>
<th>Net Minutes Worked (hours worked - exception)</th>
<th>% of Productivity</th>
</tr>
<% 'set up date values
dim year2, day2, month2
year2 = Trim(Request.form("ddyear"))
month2 = Trim(Request.form("ddmonth"))
'open up the cuot data for the month
Set rstData1 = Server.CreateObject("ADODB.Recordset") 'cuot
'open up the table to grab the names of those who entered data during that month selected
rstDATA1.open "SELECT DISTINCT [name] FROM cuot WHERE month(date)= '" & month2 & "' and year(date) ='" & year2 & "' ORDER BY [name]", cnn, adOpenKeyset
Set rstData3 = Server.CreateObject("ADODB.Recordset") 'hours worked
Set rstData4 = Server.CreateObject("ADODB.Recordset") 'exception
do until rstDATA1.eof = true
%><tr>
<td><%=rstDATA1("name")%> </td>
<% 'do the math calculations for minute achieved
Set rstData0 = Server.CreateObject("ADODB.Recordset") 'cuot
rstDATA0.open "SELECT count(toc) as COUNT1, toc FROM cuot WHERE [name] = '" & replace(rstDATA1("name"), "'", "''") & "' and month(date)= '" & month2 & "' and year(date) ='" & year2 & "' GROUP BY toc ORDER BY toc", cnn, adOpenKeyset
rstDATA.movefirst 'tv table to get "minutes achieved"
rstDATA0.movefirst 'cuot list
CUachieved = 0
do until rstDATA0.eof = true
'loop through rstDATA.toc until match found for rstDATA0.toc
do until trim(rstDATA("toc")) = trim(rstDATA0("toc"))
rstDATA.movenext
loop
if rstDATA("per_day") <> "0" then CUachieved = cDBL(CUachieved) + (cDBL(rstDATA0("COUNT1"))/cDBL(rstDATA("per_day"))*450)
rstDATA.movenext
rstDATA0.movenext
loop
%><td><%=round(CUachieved)%> </td>
<% 'open up the hoursworked table
rstDATA3.open "Select * FROM monthlyhr WHERE [name] = '" & replace(rstDATA1("name"), "'", "''") & "' and month(date) ='" & month2 & "' and year(date) = '" & year2 & "'", cnn, adOpenKeyset
'should only ever be one record, so only check if there are no records
if rstDATA3.eof = true then
%><td>N/A</td>
<% 'net minutes worked
%><td>N/A</td>
<% '% of productivity
else
'open up the exception table
'get approved exception
rstDATA4.open "Select [name], sum(approval) as SUM1 from [exception] where [name] = '" & replace(rstDATA1("name"), "'", "''") & "' and month(date) ='" & month2 & "' and year(date) = '" & year2 & "' GROUP BY [name]", cnn, adOpenKeyset
if rstDATA4.eof = true then
exception2 = 0
else
exception2 = rstDATA4("sum1")
end if
rstDATA4.close
'do the math for actual (hours worked + overtime - leave -exception)
hoursworked2 = (cDBL(rstDATA3("hours")) + cDBL(rstDATA3("ot")) - cDBL(rstDATA3("leave")) - cDBL(exception2))
%><td><%=hoursworked2*60%> </td>
<%
'calculate percentage of csu+ops/minutes worked
percentTOTAL = ROUND(cDBL(CUachieved)/(cDBL(hoursworked2)*60)*100) 'percent
%><td><%=percentTOTAL%> </td>
</tr>
<tr>
<%
end if
rstDATA1.movenext
rstDATA3.close
loop
rstDATA.close 'close all databases
set rstDATA = nothing
rstDATA1.close
set rstDATA1 = nothing
set rstDATA3 = nothing
set rstDATA4 = nothing
cnn.close
set cnn=nothing
%>
</tr>
</table>
<%
end if 'end query%>
</blockquote>
</div>
<!-- InstanceEndEditable --></div>
<!-- End of div.blackborder -->
</div>
答案 1 :(得分:0)
我能够解决Microsoft Access错误消息。在我的编码中,有一个连接到第二个数据库,列出了标题。几个月前我创建了新的标题,因为我希望它们出现在行的顶部,我通过添加空格来缩进它们。一旦我删除了所有新标题的sapce,过去几个月的错误消息就消失了,报告显示完美。
感谢大家的建议。