Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2004, 04:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default Process stops

Can somebody help here, I cannot for the life of me figure out why this will stop looping thru the main top selection. I am selecting what files to archive from the request.form, then I archive any comments for the files, this works perfect. When I add the part to delete old files and versions the loop stops after the first record.

'Get the Request on what pages to delete
For i = 1 To Request.Form("Archive").Count

    strSQL = "SELECT File_ID, FileName, Proof_Count " &_
                    "FROM FileHolder " &_
                    "WHERE File_ID = " & Request.Form("Archive")(i) & ";"

    'Response.Write strSQL & "<BR><BR>"

    Set objCmd = Server.CreateObject("ADODB.Command")
    objCmd.ActiveConnection = objConn

    objCmd.CommandText = strSQL
    objCmd.CommandType = adCmdText

    Set objSelect = objCmd.Execute
    Set objCmd = Nothing
    If Not objSelect.EOF Then
'______
'This is where my problem is stopping. It will run the ArchiveCommentsData Sub like it should.
'Then when I add the DeleteFiles Function it will stop looping.
'________
        Call ArchiveCommentsData(objSelect("File_ID"))
        Response.Write DeleteFiles(objSelect("Proof_Count"), objSelect("Ad_FileName"))
    End If

    objSelect.Close()
    Set objSelect = Nothing

Next


Function DeleteFiles(intProofCount, strAdName)

    Response.Write intProofCount & "--Inside deleted files<BR>"
    Response.Write strAdName & "--Inside deleted files<BR>"

    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'____Check to see if there are versions

    If intProofCount = 1 Then
    '____No versions

        strPath_Live = "c:\FileStorage\develope\Fun\" & strAdName

        If objFSO.FileExists(strPath_Live) Then
            objFSO.DeleteFile(strPath_Live)
            strEventText =strEventText & strPath_Live & "<BR>"
        Else
            strEventText =strEventText & "Did not find the file-" & "<BR>"
        End If

    ElseIf intProofCount > 1 Then
    '____Additional Versions
        For i = 1 To intProofCount
            strPath_Live = "c:\FileStorage\develope\Fun\" & strAdName

            If i = 1 Then
                If objFSO.FileExists(strPath_Live) Then
                    objFSO.DeleteFile(strPath_Live)
                    strEventText =strEventText & strPath_Live & "<BR>"
                Else
                    strEventText =strEventText & "Did not find the file-" & strPath_Live & "<BR>"
                End If
            End If
            '___This is for the version naming convention
                If i < 10 Then
                    strFixCount = "0" & i
                Else
                    strFixCount = i
                End If

            strPath_Version = "c:\FileStorage\develope\Fun\versions\" & strFixCount & "_" & strAdName

            If objFSO.FileExists(strPath_Version) Then
                objFSO.DeleteFile(strPath_Version)
                strEventText =strEventText & strPath_Version & "<BR>"
            Else
                strEventText =strEventText & "Did not find the file-" & strPath_Version & "<BR>"
            End If
        Next

    End If

    Response.Write strEventText & "<BR>"

    DeleteFiles = "These Files Removed<BR>"

    Set objFSO = nothing

End Function

I hope this is not confusing and for any help

Mike
__________________
Peace
Mike
http://www.eclecticpixel.com
 
Old September 24th, 2004, 05:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

I am not sure what this does.
Code:
Request.Form("Archive").Count
What is Archive there in the form?
Code:
For i = 1 To intProofCount
            strPath_Live = "c:\FileStorage\develope\Fun\" & strAdName

            If i = 1 Then
                If objFSO.FileExists(strPath_Live) Then
                    objFSO.DeleteFile(strPath_Live)
                    strEventText =strEventText & strPath_Live & "<BR>"
                Else
                    strEventText =strEventText & "Did not find the file-" & strPath_Live & "<BR>"
                End If
            End If
            '___This is for the version naming convention
                If i < 10 Then
                    strFixCount = "0" & i
                Else
                    strFixCount = i
                End If

            strPath_Version = "c:\FileStorage\develope\Fun\versions\" & strFixCount & "_" & strAdName

            If objFSO.FileExists(strPath_Version) Then
                objFSO.DeleteFile(strPath_Version)
                strEventText =strEventText & strPath_Version & "<BR>"
            Else
                strEventText =strEventText & "Did not find the file-" & strPath_Version & "<BR>"
            End If
        Next
        Does the code in red and that in blue not look similar for the first time, whe i=1? Does it mean that there are versions of filenames starting with "1" and "01" separately? Both red and blue codes are executed when i=1. Is that repetitive?

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 27th, 2004, 09:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks HappyGV for you help

The Request.Form("Archive").Count is from a form on the previous page that sends over the record IDs of what files to archive.

So this is the basics of everything I have going.
1-Receive ID's from a form on the previous page
2-Select the File information to archive from the database
3-Archive the Comments
4-Delete The Actual Files and versions
5-Move onto the next record in the database from the Request Form information.

I have done some more testing in my DeleteFiles Function I deleted everything to narrow down what is happening and have gotten to this point were the problem is. intProofCount is the numbers of versions for strAdName.

Function DeleteFiles(intProofCount, strAdName)
Response.Write intProofCount & "--Inside deleted files<BR>"
Response.Write strAdName & "--Inside deleted files<BR>"
For i = 1 To intProofCount
        Response.Write i & "<BR>"
Next
End Function

I have found that it will work correctly. If I do the Response.Writes for the intProofCount and strAdName, then it will move to the next record in the database. But then I add the For loop, It stops after writing the i and will not move on to the next record in the database. Any ideas??

Thanks
Mike

Thanks
Mike
 
Old September 27th, 2004, 10:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I can't believe I was doing this. I just figured out that I was using the variable i variable in both my main loop and in the funtion loop so I was giving it a new value and it was stopping, it's always the simple thing that gets you.

Thanks
Mike





Similar Threads
Thread Thread Starter Forum Replies Last Post
process.startinfo opens new instance of process Anypond General .NET 0 August 28th, 2008 05:35 AM
Tomcat suddenly stops after starts annumol Apache Tomcat 2 February 9th, 2008 01:32 PM
No Error, Just stops when no records feldhege ADO.NET 1 May 19th, 2006 07:30 AM
Service Starts and Stops rodmcleay .NET Web Services 1 January 30th, 2006 04:30 AM
Timer stops by itself when application is running hplim18 VB.NET 1 August 27th, 2004 05:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.