Problems Displaying "Nth" Record

Results 1 to 2 of 2

Thread: Problems Displaying "Nth" Record

  1. #1
    Jim Jones Guest

    Default Problems Displaying "Nth" Record

    I&#039m looking to display results from my database 10 at a time. The first page displays correctly, however, this error appears when pressing the "next" button for the next 10 results.<BR><BR>Microsoft VBScript runtime error &#039 800a0009&#039 <BR>Subscript out of range: &#039[number: 0]&#039 <BR>/Matcher/search.asp, line 41 <BR><BR>For some reason it only displays part of the RecordSet. Need Help? Will add code. Here&#039s the database string used if helpful.<BR><BR>sql="SELECT *"<BR> sql = sql & " FROM Users WHERE " & BaseSQL<BR> If SearchSQL &#060;&#062; "" then sql = sql & " AND " & SearchSQL<BR> sql = sql & " AND GroupID&#062;1"<BR> Set strSQL = Conn.Execute(sql)<BR> rs.Open strSQL, Conn<BR><BR><BR>

  2. #2
    Ramakrishna Guest

    Default RE: Problems Displaying

    I think you can try the following code<BR>Public Function GetRecords(BaseSQL As String,SearchSQL as string<BR> Optional iLen As Integer, Optional iStart As Integer ) As Variant<BR><BR> Dim conn As ADODB.Connection<BR> Dim rs As ADODB.Recordset<BR> Dim strSQL As String<BR> Dim vArrayTemp As Variant<BR> <BR> On Error GoTo ErrHnd<BR> <BR> &#039 Open Recordset and Connection<BR> Set Conn = New ADODB.Connection<BR> Set rs = New ADODB.Recordset<BR> <BR> objcon.Open DBNAME<BR> <BR> sql="SELECT *"<BR>sql = sql & " FROM Users WHERE " & BaseSQL<BR>If SearchSQL &#060;&#062; "" then sql = sql & " AND " & SearchSQL<BR>sql = sql & " AND GroupID&#062;1"<BR>Set strSQL = Conn.Execute(sql)<BR>rs.Open strSQL, Conn<BR><BR> If rs.EOF And rs.BOF Then<BR> ReDim vArrayTemp(1, 1) As String<BR> vArrayTemp(0, 0) = "Empty"<BR> GetRecords = vArrayTemp<BR> &#039 Close and destroy Recordset and Connection<BR> rs.Close<BR> Set rs = Nothing<BR> conn.Close<BR> Set conn = Nothing<BR> Exit Function<BR> End If<BR> If iStart &#062; 0 Then<BR> rs.Move iStart<BR> GetRecords = rs.GetRows(iLen)<BR> Else<BR> GetRecords = rs.GetRows()<BR> End If<BR> <BR> <BR> &#039 Close and destroy Recordset and Connection<BR> rs.Close<BR> Set rs= Nothing<BR> conn.Close<BR> Set conn = Nothing<BR> <BR>End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts