By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,760 Members | 1,585 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,760 IT Pros & Developers. It's quick & easy.

Recordset not fully popoulated?

P: n/a
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
%>
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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" <ba****@nospamblueyonder.co.uk> wrote in message
news:63***********************@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
%>

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.