本文介绍了不允许操作......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我收到错误:对象关闭时不允许操作。 代码行如下。我无法想象为什么对象会被关闭 它会说它会是,我刚刚在线上打开它。这是一个更大的循环中的所有,但是循环似乎工作正常,其中的其他 插入语句似乎没问题。有什么建议吗? Dim cmsRS,cmsSQL Dim insRS,insSQL 设置cmsRS = Server.CreateObject( " ADODB.Recordset") 设置insRS = Server.CreateObject(" ADODB.Recordset") cmsSQL =" SELECT ClientsFileNumber FROM TblOrder WHERE FileNumber =''" & Request.Form(" ref"& intR)& "''AND ClientCode =''CMSNY''" cmsRS.Open cmsSQL," DSN = kasecure1; uid = sa; pwd = pcbs" 如果不是cmsRS.EOF那么 insSQL =" INSERT INTO CMS(FileNumber,StatusDate,StatusTime, StatusComment)VALUES(''' ;& Request.Form(" ref"& intR)&"'',''"& Request.Form(" sd"& intR&" ; _"& intsc&"'',''"& adstime&"'',''检查 日期已设为& isd& "'')" ''/开始问题 insRS.Open insSQL,DSN = kasecure1; uid = sa; pwd = pcbs ; insRS.Close''错误在这条线上 ''/结束问题 结束如果 cmsRS.Close 设置cmsRS =没什么 设置insRS = NothingI''m getting an error: "Operation is not allowed when the object is closed."on the lines of code below. I can''t imagine why the object would be closedwhere it says it will be, I''ve just opened it on the line before. This isall within a larger loop, but the loop seems to be working fine and otherinsert statements within it seem ok. Any suggestions?Dim cmsRS, cmsSQLDim insRS, insSQLSet cmsRS = Server.CreateObject("ADODB.Recordset")Set insRS = Server.CreateObject("ADODB.Recordset")cmsSQL = "SELECT ClientsFileNumber FROM TblOrder WHERE FileNumber = ''" &Request.Form("ref" & intR) & "'' AND ClientCode = ''CMSNY''"cmsRS.Open cmsSQL, "DSN=kasecure1;uid=sa;pwd=pcbs"If NOT cmsRS.EOF TheninsSQL = "INSERT INTO CMS (FileNumber, StatusDate, StatusTime,StatusComment) VALUES(''" & Request.Form("ref" & intR) & "'', ''" &Request.Form("sd" & intR & "_" & intsc & "'', ''" & adstime & "'', ''InspectionDate has been set for " & isd & "'')"'' / Begin ProbleminsRS.Open insSQL, "DSN=kasecure1;uid=sa;pwd=pcbs"insRS.Close '' Errors on this line'' / End ProblemEnd IfcmsRS.CloseSet cmsRS = NothingSet insRS = Nothing推荐答案 由于您没有从查询,当然你不要t 此时有一个开放的重新设置。摆脱第二个记录集的createobject 语句并使用它来执行一个查询b $ b不返回记录: cn.Execute insSQL ,, 129''129 = adCmdText(1)+ adExecuteNoRecords(128) HTH, Bob Barrows - Microsoft MVP - ASP / ASP.NET 请回复到新闻组。我的From 标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。Since there were no records returned from your query, of course you don''thave an open re cordset at this point. Get rid of that createobjectstatement for the second recordset and use this to execute a query that doesnot return records:cn.Execute insSQL,,129 ''129=adCmdText(1)+adExecuteNoRecords(128)HTH,Bob Barrows--Microsoft MVP -- ASP/ASP.NETPlease reply to the newsgroup. The email account listed in my Fromheader is my spam trap, so I don''t check it very often. You will get aquicker response by posting to the newsgroup. 这篇关于不允许操作......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-05 06:45