Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional 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 February 24th, 2006, 07:24 PM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Subscript out of range: '[number: 0]'

Can someone please help me with this error?
************************************************** *
Microsoft VBScript runtime error '800a0009'
Subscript out of range: '[number: 0]'

/admin/News.asp, line 73
************************************************** *

Here is the code:



<%
Dim oRSNews, strStatusMsg,iNewsID, aResults, oRS
Dim objUpload, strFileName, strPath

'' Instantiate Upload Class
Set objUpload = New clsUpload
Set aResults = Server.CreateObject("Scripting.Dictionary")


If objUpload.Fields("EditID").Value <> "" Then
 Dim x
 Set oRS = Server.CreateObject("ADODB.Recordset")

 iNewsID = objUpload.Fields("EditID").Value
 IF NOT IsNumeric(iNewsID) OR iNewsID="" Then
  iNewsID = -1
 End IF

 SQL = "SELECT * FROM tblNews WHERE NewsID = " & iNewsID & ""
 oRS.Open SQL, DbObj, adOpenDynamic, adLockOptimistic, adCmdText
 Do While Not oRS.EOF
  For x = 0 To oRS.Fields.Count - 1
   aResults.Add oRS.Fields(x).Name, oRS(x).Value
  Next
  oRS.MoveNext
 Loop

End If

If objUpload.Fields("title").Value <> "" Then

 Set oRSNews = Server.CreateObject("ADODB.Recordset")

 ''Clean Variables
 iNewsID = objUpload.Fields("NewsID").Value
 IF NOT IsNumeric(iNewsID) OR iNewsID="" Then
  iNewsID = -1
 End IF

 SQL = "SELECT * FROM tblNews WHERE NewsID = " & iNewsID & ""
 'SQL = "INSERT INTO tblNews(AuditDate,AuditID,Approved,NewsDate,Title, Highlight ) values('" & _
 ' Date() & "','1','No','01/01/2004','testtitle2','testhightlight2' )"
 'response.write SQL
 'DbObj.Execute SQL
 oRSNews.Open SQL, DbObj, adOpenDynamic, adLockOptimistic, adCmdText


    oRSNews.Addnew
    oRSNews.Fields("AuditDate") = Now()
 oRSNews.Fields("AuditID") = 1
 oRSNews.Fields("Approved") = False
 oRSNews.Fields("NewsDate") = objUpload.Fields("newsdate").Value
 oRSNews.Fields("Title") = objUpload.Fields("title").Value
 oRSNews.Fields("Highlight") = objUpload.Fields("highlight").Value
 oRSNews.Fields("PDF") = "PDFFILE"
 If Session("sPermUsers") Then
  oRSNews.Fields("Approved") = objUpload.Fields("approved").Value
 End If

 oRSNews.Update

 'If objUpload.Fields("pdffile").FilePath <> "" Then

71 ' Grab the file name
72 strFileName = "DKS" & _
73 DatePart("yyyy", objUpload.Fields("newsdate").Value) & _
74 DatePart("m", objUpload.Fields("newsdate").Value) & _
75 DatePart("d", objUpload.Fields("newsdate").Value) & _
         "_" & oRSNews.Fields("NewsID").Value & _
         "." & StrReverse(Split(StrReverse(objUpload.Fields("pdff ile").FilePath), ".", -1, 1)(0))

  ' Compile path to save file to
  strPath = Server.MapPath("/news") & "\" & strFileName

  ' Save the binary data to the file system
  objUpload("pdffile").SaveAs strPath

  oRSNews.Fields("PDF") = strFileName
  oRSNews.Update
 'End If


    strStatusMsg = "News Added! " & objUpload.Fields("title").Value
    Set objUpload = Nothing
Else
 'strStatusMsg = "No Add" '& oRSNews.Status
End If
%>


Any ideas would be greatly appreciated.
Thanks,
Jim






Similar Threads
Thread Thread Starter Forum Replies Last Post
Array, Subscript out of range. koss77 VB How-To 4 August 21st, 2006 09:35 AM
Subscript out of range rfrancisco Classic ASP Components 1 February 13th, 2006 08:25 PM
Subscript out of range crmpicco Classic ASP Basics 4 March 22nd, 2005 06:55 PM
Subscript out of range: '[number: 49]' hameed Classic ASP Databases 2 August 5th, 2004 08:32 AM
Problem of "Subscript out of range " liorlank Classic ASP Components 2 November 26th, 2003 10:45 AM





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