p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: File Upload and Hanging


Message #1 by "Nadia Hamza" <hamzan@h...> on Tue, 11 Sep 2001 18:36:34
Hi, I've got the following code which used to work on a server and now 
speradically works.  I don't get any error messages but it hangs the 
system.  Any suggestions would be greatly appreciated.  Thanks!

Nadia	


Dim objRec, sql, sql2, blnFirstParameter, test, blnSponsor, upl	
    Dim picture1, picture2, picture3, picture4, picture5, picture6, 
picture7, picture8
    Dim strFilename1, strFilename2, strFilename3, strFilename4, 
strFilename5, strFilename6
    Dim strFilename7, strFilename8

	' recordset object

    set upl = Server.CreateObject("SoftArtisans.FileUp")

    upl.Path = "f:\webserver\ftp\sites\murraywilliamson.com\upload"

    sql = "Update Listings Set"

    ' Set the first parameter flag to true
    blnFirstParameter = True

    ' Update Price if present
    If Len(upl.Form("Price"))>0 Then
       'Add the value to the SQL string
       sql = sql & " Price = '" & _
       CStr(upl.Form("Price")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

     If Len(upl.Form("Classification"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Classification = '"
       Else
          sql = sql & ", Classification = '"
       End If
       sql = sql & CStr(upl.Form("Classification")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

    If Len(upl.Form("Type"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Type = '"
       Else
          sql = sql & ", Type = '"
       End If
       sql = sql & CStr(upl.Form("Type")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

    If Len(upl.Form("Size"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Size = '"
       Else
          sql = sql & ", Size = '"
       End If
       sql = sql & CStr(upl.Form("Size")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

    If Len(upl.Form("Location"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Location = '"
       Else
          sql = sql & ", Location = '"
       End If
       sql = sql & CStr(upl.Form("Location")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

   If Len(upl.Form("Features"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Features = '"
       Else
          sql = sql & ", Features = '"
       End If
       sql = sql & CStr(upl.Form("Features")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If


    Response.Write "Image1" & Len(upl.Form("Image1"))
    upl.Form("Image1").Save
    strFilename1 = Mid(upl.Form("Image1").UserFilename, InstrRev(upl.Form
("Image1").UserFilename, "\") + 1)  

     If Len(strFilename1) < 1 Then
          strFilename1 = "blank.jpg"
        If Len(upl.Form("Image1a"))>0 Then
           strFilename1 = upl.Form("Image1a")
        End If
     End If

    If Len(strFilename1)>0 Then  
        If blnFirstParameter Then
          sql = sql & " Image1 = '"
        Else
          sql = sql & ", Image1 = '"
        End If
        sql = sql & CStr(strFilename1) & "'"
        ' Set the first parameter flag to false
       blnFirstParameter = False
     End If

    ' Response.Write "Image2" & Len(upl.Form("Image2"))
    upl.Form("Image2").Save
    strFilename2 = Mid(upl.Form("Image2").UserFilename, InstrRev(upl.Form
("Image2").UserFilename, "\") + 1)  

     If Len(strFilename2) < 1 Then
       ' Add the value to the SQL string
          strFilename2 = "blank.jpg"
          If Len(upl.Form("Image2a"))>0 Then
                strFilename2 = upl.Form("Image2a")
          End If
     End If

    If Len(strFilename2)>0 Then  
        If blnFirstParameter Then
          sql = sql & " Image2 = '"
        Else
          sql = sql & ", Image2 = '"
        End If
        sql = sql & CStr(strFilename2) & "'"
        ' Set the first parameter flag to false
       blnFirstParameter = False
     End If

    If Len(upl.Form("Caption2"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Caption2 = '"
       Else
          sql = sql & ", Caption2 = '"
       End If
       sql = sql & CStr(upl.Form("Caption2")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

    upl.Form("Image3").Save
    strFilename3 = Mid(upl.Form("Image3").UserFilename, InstrRev(upl.Form
("Image3").UserFilename, "\") + 1)  

     If Len(strFilename3) < 1 Then
          strFilename3 = "blank.jpg"
        If Len(upl.Form("Image3a"))>0 Then
           strFilename3 = upl.Form("Image3a")
        End If
     End If

     If Len(strFilename3)>0 Then  
        If blnFirstParameter Then
          sql = sql & " Image3 = '"
        Else
          sql = sql & ", Image3 = '"
        End If
        sql = sql & CStr(strFilename3) & "'"
        ' Set the first parameter flag to false
       blnFirstParameter = False
     End If

    If Len(upl.Form("Caption3"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Caption3 = '"
       Else
          sql = sql & ", Caption3 = '"
       End If
       sql = sql & CStr(upl.Form("Caption3")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

    upl.Form("Image4").Save
    strFilename4 = Mid(upl.Form("Image4").UserFilename, InstrRev(upl.Form
("Image4").UserFilename, "\") + 1)  

     If Len(strFilename4) < 1 Then
          strFilename4 = "blank.jpg"
        If Len(upl.Form("Image4a"))>0 Then
           strFilename4 = upl.Form("Image4a")
        End If
     End If
     If Len(strFilename4)>0 Then  
        If blnFirstParameter Then
          sql = sql & " Image4 = '"
        Else
          sql = sql & ", Image4 = '"
        End If
        sql = sql & CStr(strFilename4) & "'"
        ' Set the first parameter flag to false
       blnFirstParameter = False
     End If

    If Len(upl.Form("Caption4"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Caption4 = '"
       Else
          sql = sql & ", Caption4 = '"
       End If
       sql = sql & CStr(upl.Form("Caption4")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

    upl.Form("Image5").Save
    strFilename5 = Mid(upl.Form("Image5").UserFilename, InstrRev(upl.Form
("Image5").UserFilename, "\") + 1)  

     If Len(strFilename5) < 1 Then
          strFilename5 = "blank.jpg"
        If Len(upl.Form("Image5a"))>0 Then
           strFilename5 = upl.Form("Image5a")
        End If
     End If
     If Len(strFilename5)>0 Then  
        If blnFirstParameter Then
          sql = sql & " Image5 = '"
        Else
          sql = sql & ", Image5 = '"
        End If
        sql = sql & CStr(strFilename5) & "'"
        ' Set the first parameter flag to false
       blnFirstParameter = False
     End If

    If Len(upl.Form("Caption5"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Caption5 = '"
       Else
          sql = sql & ", Caption5 = '"
       End If
       sql = sql & CStr(upl.Form("Caption5")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

    upl.Form("Image6").Save
    strFilename6 = Mid(upl.Form("Image6").UserFilename, InstrRev(upl.Form
("Image6").UserFilename, "\") + 1)  

     If Len(strFilename6) < 1 Then
          strFilename6 = "blank.jpg"
        If Len(upl.Form("Image6a"))>0 Then
           strFilename6 = upl.Form("Image6a")
        End If
     End If
     If Len(strFilename6)>0 Then  
        If blnFirstParameter Then
          sql = sql & " Image6 = '"
        Else
          sql = sql & ", Image6 = '"
        End If
        sql = sql & CStr(strFilename6) & "'"
        ' Set the first parameter flag to false
       blnFirstParameter = False
     End If

    If Len(upl.Form("Caption6"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Caption6 = '"
       Else
          sql = sql & ", Caption6 = '"
       End If
       sql = sql & CStr(upl.Form("Caption6")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

    upl.Form("Image7").Save
    strFilename7 = Mid(upl.Form("Image7").UserFilename, InstrRev(upl.Form
("Image7").UserFilename, "\") + 1)  

     If Len(strFilename7) < 1 Then
          strFilename7 = "blank.jpg"
        If Len(upl.Form("Image7a"))>0 Then
           strFilename7 = upl.Form("Image7a")
        End If
     End If
     If Len(strFilename7)>0 Then  
        If blnFirstParameter Then
          sql = sql & " Image7 = '"
        Else
          sql = sql & ", Image7 = '"
        End If
        sql = sql & CStr(strFilename7) & "'"
        ' Set the first parameter flag to false
       blnFirstParameter = False
     End If

    If Len(upl.Form("Caption7"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Caption7 = '"
       Else
          sql = sql & ", Caption7 = '"
       End If
       sql = sql & CStr(upl.Form("Caption7")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

    upl.Form("Image8").Save
    strFilename8 = Mid(upl.Form("Image8").UserFilename, InstrRev(upl.Form
("Image8").UserFilename, "\") + 1)

     If Len(strFilename8) < 1 Then
          strFilename8 = "blank.jpg"
        If Len(upl.Form("Image8a"))>0 Then
           strFilename8 = upl.Form("Image8a")
        End If
     End If
     If Len(strFilename8)>0 Then  
        If blnFirstParameter Then
          sql = sql & " Image8 = '"
        Else
          sql = sql & ", Image8 = '"
        End If
        sql = sql & CStr(strFilename8) & "'"
        ' Set the first parameter flag to false
       blnFirstParameter = False
     End If

    If Len(upl.Form("Caption8"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Caption8 = '"
       Else
          sql = sql & ", Caption8 = '"
       End If
       sql = sql & CStr(upl.Form("Caption8")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If



   If Len(upl.Form("Sold"))>0 Then
       ' Add the value to the SQL string
       If blnFirstParameter Then
          sql = sql & " Sold = '"
       Else
          sql = sql & ", Sold = '"
       End If
       sql = sql & CStr(upl.Form("Sold")) & "'"
       ' Set the first parameter flag to false
       blnFirstParameter = False
    End If

  ' Set the Where clause
    Response.Write "SQL = " & sql
    sql = sql & " Where ListingNumber = " & CLng(upl.Form
("ListingNumber")) & ";"
    
    	' create the recordset object
	Set objRec = Server.CreateObject ("ADODB.Recordset")

	' now open it
	objRec.Open sql, strConnect, adOpenStatic, _ 
    adLockReadOnly, adCmdText

    ' Response.Write sql
  

    Set objRec = Nothing      

  Return to Index