Re: Recordset not fully popoulated?

From: Aaron Bertrand [MVP] (aaron_at_TRASHaspfaq.com)
Date: 03/16/04


Date: Tue, 16 Mar 2004 10:34:43 -0500

Name your columns, and drop this lazy SELECT * syntax. Use set objRS =
objConn.Execute()... never mind this ADODB.Recordset.Open stuff. Also, as
soon as you open the recordset, assign rs(0) to a variable. And make sure
you have the most recent version of MDAC.

(See http://www.aspfaq.com/2188 for more info.)

There is no such thing, by the way, as ASP jumping to a line of code before
a previous line has finished executing.

You also might want to guard against EOF blowing up your page. Your table
has rows now, but it might not later.

-- 
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Andrew Banks" <banksy@nospamblueyonder.co.uk> wrote in message
news:63C5c.17960$DJ2.389294244@news-text.cableinet.net...
> I've been handed an ASP project and having worked on .NET for the past
year
> I have completely forgotten what to do.
>
> I am querying a SQL server DB and returning XML. The following code seems
to
> work for small amounts of data but with any thing significant (10
records!)
> the XML is returned incomplete.
>
> After testing various things I can only assume that when the
> Response.Write(objRS(0)) line is reached, that the recordset has not been
> fully loaded with the data.
>
> In .NET I use an executescalar() command for returning data where I know
> there will only be one item returned. Is there anything similar in classic
> ASP or can anyone point out the problem with this code?
>
> Thanks, Andrew
>
> <%
> Set objConn = Server.CreateObject("ADODB.Connection")
> objConn.ConnectionString = "dsn=SERVER;uid=sa;"
> objConn.Open
> strSQL = "SELECT * FROM viewPhoneBook FOR XML AUTO"
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objRS.Open strSQL, objConn
> Response.Write("<?xml version='1.0' encoding='UTF-8'?>")
> Response.Write("<root>")
> Response.Write(objRS(0))
> Response.Write("</root>")
> Set objRS = Nothing
> Set objConn = Nothing
> %>
>
>


Relevant Pages

  • Re: error no record
    ... : Dim UserName ... : 'Create the recordset object ... Set objRS = Nothing ... Set objConn = Nothing ...
    (microsoft.public.scripting.vbscript)
  • Re: error when trying to delete object
    ... Dim objConn ' ADO Recordset Object ... Set objConn = Server.CreateObject ... Set objRS = Server.CreateObject ... >: Dim strSQL ...
    (microsoft.public.inetserver.asp.db)
  • Re: Hiding ASP source code
    ... Set objRS = cmd.Execute ... Dim sqlString As String ... Dim objConn As ADODB.Connection ... Call the object from ASP ...
    (microsoft.public.inetserver.asp.general)
  • Re: User registration system: shows the minimum age among the users.
    ... >I can't shows the minimum age among the users. ... > Set objConn = Server.CreateObject ... Create a recordset object instance and retrieve the information ... > Set objRs = objConn.Execute ...
    (microsoft.public.data.ado)
  • ASP - Problem with linked and unlinked table from MS Access 97
    ... Set objRS = CreateObject ... I receive different data when I generate query in MS Access 97 and ASP ... I have also noticed that it is connected with linked table to the database ...
    (microsoft.public.scripting.vbscript)