Re: Recordset not fully popoulated?
From: Aaron Bertrand [MVP] (aaron_at_TRASHaspfaq.com)
Date: 03/16/04
- Next message: Ray at <%=sLocation%> [MVP]: "Re: Weird ASP Error"
- Previous message: Aaron Bertrand [MVP]: "Re: Putting a delay into a loop ?"
- In reply to: Andrew Banks: "Recordset not fully popoulated?"
- Messages sorted by: [ date ] [ thread ]
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 > %> > >
- Next message: Ray at <%=sLocation%> [MVP]: "Re: Weird ASP Error"
- Previous message: Aaron Bertrand [MVP]: "Re: Putting a delay into a loop ?"
- In reply to: Andrew Banks: "Recordset not fully popoulated?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|