【问题标题】:Classic ASP and MS Access Batch Update经典 ASP 和 MS Access 批量更新
【发布时间】:2013-11-01 00:10:41
【问题描述】:

我正在使用以下代码使用 Classic Asp 更新 Access 数据库:

<%@ Language=VBScript %>
<% Option Explicit %>
<%
Response.Buffer = True
'First, we need to get the total number of items that could be updated
Dim iCount
iCount = Request("Count")

'We need to obtain each cost and ID
Dim strstudent, strcourse, strgrade, strcomments

'We will also need to build a SQL statement
Dim strSQL

Dim conn


set conn=server.CreateObject("ADODB.connection")
conn.ConnectionString="provider=Microsoft.jet.OLEDB.4.0;data source=C:\db\agsystem.mdb"
conn.Open
'Now, we want to loop through each form element
Dim iLoop
For iLoop = 0 to iCount
'student data
strstudent = Request(iLoop & ".Student")
'course data
strcourse = Request(iLoop & ".course")
'grade
if isNull(Request(iLoop & ".grade")) or Request(iLoop & ".grade")="" then
strgrade="null"
else
strgrade= Request(iLoop & ".grade")
end if
if isNull(Request(iLoop & ".comments"))  or Request(iLoop & ".comments")="" then
strcomments=null
else
strcomments=Request(iLoop & ".comments")
end if
strSQL = "UPDATE testing SET semester2 = " & strgrade & ", commentss=" & "'" & strcomments & "'" & "  WHERE newstudentid = " &"'"& strstudent&"'" & " and Courseid = " & "'"& strcourse & "'"
conn.Execute strSQL
Next

conn.Close
Set conn = Nothing

Response.Redirect "protected.asp"
%>

问题在于,在服务器中进行测试时,它会更新而没有任何问题。但是当从无线网络访问时,它不会更新。

要更新的目标表有大约 27,000 条记录 我需要知道我做错了什么或者是否有其他方法。

【问题讨论】:

  • 对不起,意思是当从本地服务器更新时,它更新没有任何问题。但是当从 WAN 访问时,它不会更新
  • 实际上只有某些记录是从本地更新的。

标签: asp-classic vbscript ms-access-2007 batch-updates


【解决方案1】:

我仔细分析情况后发现了错误。

主键中包含空格的记录(例如“2 OR 13”)不会更新。但是像“2CEN13”这样的主键中没有空格的记录可以完美更新。我没有时间在我的 asp 代码中解决它,所以我用空格编辑了所有记录并解决了问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 2015-08-13
    • 1970-01-01
    • 2013-03-25
    • 2016-01-09
    相关资源
    最近更新 更多