Plese help in this code , i have mentioned comment where error comes -
For iox = nMinID To nTotID
-
-
On Error GoTo Hell
-
-
Call Progress(iox, nTotID)
-
-
-
con.Execute "delete from ATACZ_Account_Data"
-
-
'error comes in this line
-
Rs.Open "insert into ATACZ_Account_Data select * from ESTMT_ATACZ_Account_Data where [supress] ='F' and [ATACZ-EMAIL] <>'' and id =" & iox, con, adOpenDynamic, adLockOptimistic
-
-
Rs.Open "select * from ATACZ_Account_Data where id =" & iox, con, adOpenDynamic, adLockOptimistic
-
-
Set Rs.ActiveConnection = Nothing
-
-
Counter = Counter + 1
-
-
DoEvents
-
-
If Counter Mod 1000 = 0 Then
-
-
If Len(Dir("C:\PNBApplication\Temp\*.ps")) > 0 Then
-
'deepak Kill "C:\PNBApplication\Temp\*.ps"
-
End If
-
-
If Len(Dir("C:\PNBApplication\Temp\*.csv")) > 0 Then
-
Kill "C:\PNBApplication\Temp\*.csv"
-
End If
-
-
If Len(Dir("C:\PNBApplication\Temp\*.pdf")) > 0 Then
-
Kill "C:\PNBApplication\Temp\*.pdf"
-
End If
-
-
If Len(Dir("C:\PNBApplication\Temp\out*.bat")) > 0 Then
-
Kill "C:\PNBApplication\Temp\out*.bat"
-
End If
-
Shell "taskkill /F /IM acrotray.exe", vbHide
-
-
End If
-
-
Label8.Caption = "Current Record :" & iox
-
DoEvents
-
-
-
If Not Rs.EOF Then
-
-
If Check1.Value = vbUnchecked Then
-
Report.DiscardSavedData
-
Set crpParamDefs = Report.ParameterFields
-
For Each crpParamDef In crpParamDefs
-
With crpParamDef
-
Select Case UCase(Trim(.ParameterFieldName))
-
Case "ID"
-
.ClearCurrentValueAndRange
-
.AddCurrentValue CDbl(Rs.Fields("ID"))
-
End Select
-
End With
-
Next
-
-
If OptNormal.Value = True Then Set CRXReport = CRXApp.OpenReport("C:\PNBApplication\Reports\Normal\PNB_EmailStatement_Normal.rpt")
-
If OptSilver.Value = True Then Set CRXReport = CRXApp.OpenReport("C:\PNBApplication\Reports\Silver\PNB_EmailStatement_Silver.rpt")
-
If OptGold.Value = True Then Set CRXReport = CRXApp.OpenReport("C:\PNBApplication\Reports\Gold\PNB_EmailStatement_Gold.rpt")
-
If OptCorporate.Value = True Then Set CRXReport = CRXApp.OpenReport("C:\PNBApplication\Reports\Corporate\PNB_EmailStatement_Corporate.rpt")
-
-
-
CRXReport.SelectPrinter "psscript.drv", "XeroxColor", "LPT1:"
-
CRXReport.PaperOrientation = crPortrait
-
CRXReport.PaperSize = crPaperA4
-
End If
-
-
nFileName = Format(Rs("ATACZ-DATE-CURR-STMT"), "ddMMyy") & Format(Rs("id"), "000000")
-
-
If Len(Dir("C:\PNBApplication\GeneratedFiles\" & nFileName & ".pdf")) > 0 Then
-
-
LogsWriter ("Already Exists " & nFileName & ".pdf")
-
Else
-
-
FileCounter = FileCounter + 1
-
-
-
LogsWriter ("Statement No : " & iox & " Started.")
-
Filenamx2 = "C:\PNBApplication\Temp\" & Format(Rs("ATACZ-DATE-CURR-STMT"), "ddMMyy") & Format(Rs("id"), "000000")
-
-
-
If Check1.Value = vbUnchecked Then
-
CRXReport.PrintOutEx False, 1, False, 1, -1, Filenamx2
-
End If
-
-
nAccNo = Right(Trim(CStr(Rs("ATACZ-ACCT"))), 16)
-
cPwd = nAccNo
-
-
nFileName = Format(Rs("ATACZ-DATE-CURR-STMT"), "ddMMyy") & Format(Rs("id"), "000000")
-
Open Text4.Text & "\MIS" & Format(Now(), "ddMMyy") & ".csv" For Append As #3
-
Print #3, nAccNo & "," & Rs("ATACZ-NAME-LINE-1") & "," & Rs("ATACZ-EMAIL") & "," & nFileName & ".pdf," & cPwd
-
Close #3
-
-
If Check1.Value = vbUnchecked Then
-
Open Filenamx2 For Binary As #1
-
P = String(LOF(1), vbNullChar)
-
Get 1, , P
-
Close #1
-
-
Open Filenamx2 & ".ps" For Binary As #2
-
Put #2, , P
-
Put #2, , S
-
Close #2
-
-
Kill (Filenamx2)
-
-
Open "C:\PNBApplication\Temp\out" & Rs("ID") & ".bat" For Append As #3
-
Print #3, "C:\gs\gs8.14\lib\ps2pdf14.bat -sOwnerPassword#PBXkkmmd1250 -sUserPassword#" & cPwd & " C:\PNBApplication\Temp\" & nFileName & ".ps " & Text4.Text & "\" & nFileName & ".pdf"
-
'Print #3, "del C:\PNBApplication\Temp\" & nFileName & ".ps"
-
Close #3
-
-
RetVal = Shell("C:\PNBApplication\Temp\out" & Rs("ID") & ".bat", vbHide)
-
Label9.Caption = "Generated Files :" & FileCounter
-
End If
-
-
'-i c:\sample.pdf -w owner -u user -e 40
-
'RetVal = Shell("C:\Program Files\AdultPDF\PDFEncrypt\EncryptPDF -i C:\pnbstmt\" & nFileName & ".pdf -w PBXkkmmd1250 -u " & cPwd & " -e 40", vbHide)
-
-
LogsWriter ("Statement No :" & iox & " Completed.")
-
DoEvents
-
-
End If
-
End If
-
-
Rs.Close
-
nAccNo = ""
-
cPwd = ""
-
nFileName = ""
-
DoEvents
-
If iox > nTotID Then Exit For
-
-
Hell:
-
If Len(Err.Description) <> 0 Then
-
LogsWriter ("Error : STMT No :" & iox & Err.Description)
-
End If
-
-
Next
-
2 6705
The error message is telling you that you are trying to open your recordset on a pass of your FOR-loop when it is already open, despite having a close statement somewhere near the end of the loop. Once a recordset is open you cannot (and should not) re-open it unless you close the recordset before trying to re-open it, at the end of each pass through the loop. You are also closing the active connection on each pass through the loop - which makes no sense to me.
My guess is that trying to open a recordset like this is unlikely to make sense - normally the recordset is opened BEFORE any loop processing takes place, and closed AFTER.
In addition, you have error processing code within the loop, titled somewhat unfortunately as 'Hell'. The structure of your code as it stands is not something I could recommend as good practice, being difficult to follow. I'd suggest you rewrite it, as even if you clear the errors it will still be a long code segment which has no comments to guide whoever is reading it about what it does.
At the very least, you will need to set a breakpoint so you can step and trace execution of your code line by line to determine why your Rs.Close statement is not being executed.
-Stewart
I would expect a "con.execute" instead of the "rs.open", as you're using an action query to fill the table.
Nic;o)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matthew Louden |
last post by:
The following ASP code yields the following error, but actually the new
record is stored
in database. The same error happens when the application deletes a record,
such as
sqlStmt ="delete from...
|
by: cliverama |
last post by:
help! fried brains....
asp calling a sqlserver7 stored proc which dynamically builds a
sqlstatement & passes it to sp_executesql
asp page gives the operation not allowed when object is closed...
|
by: blueblueblue2005 |
last post by:
here is a friend function of Class Array, which has two private data
member: int size, int *ptr
// Array's public member function to return size
int getSize() const { return size; }
friend...
|
by: amitbadgi |
last post by:
Hello guys I am getting this error while converting an asp applicayion
to asp.net
Exception Details: System.Runtime.InteropServices.COMException:
Operation is not allowed when the object is...
|
by: Matt |
last post by:
Got this problem that killing me...what am i doing wrong with this old
dll. When i call the function from asp i get "Operation is not allowed
when object is closed"
any clue will be...
|
by: jigu |
last post by:
<html>
<head><title>testing connection asp to mdb</title></head>
<body>
<%
dim sql_insert,sSQL
src = "C:\websites1\yourdominname\mydatabase.mdb"
sConnStr =...
|
by: Sonasang |
last post by:
Hi ,
I am creating a web page with ASP and Javascript.We have shared the foldres containg the code and all our team members are accessing the code.
There is no problem for me when i run the...
|
by: vikas1111 |
last post by:
Hi All....
I have created a form in which i call other forms from the main form ..
When i click a perticular botton twice there is an error .. Can anyone help me to solve my problem.. The error...
|
by: Sathia1 |
last post by:
Hello everyone,
I am using a module in access to write a query. I first opened a connection to my database, and wrote my query in SQL in the module itself, then I have the following codes:
...
|
by: sailoosha |
last post by:
Hi,
I am getting an error "operation not allowed when object is closed" when executing the following code. I am getting the runtime error at
While Recordset.EOF <> True
I am not sure where the...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |