Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Recordset elements failing to write to page

Reply
Thread Tools

Recordset elements failing to write to page

 
 
Greg Hurlman
Guest
Posts: n/a
 
      09-03-2003
I've got what I'm sure is a very simple problem. In an ASP page, I am trying
to write out 4 fields from a recordset in succession:

Response.Write rs("LastName")
Response.Write rs("Suffix")
Response.Write rs("FirstName")
Response.Write rs("MiddleInitial")

All fields are populated and are single terms. I would expect
"LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test record) to
be written out on the page. However, all I get is "LastNameSuffix"
(UserIII). If I move the FirstName and/or MiddleInitial to be written
first, I get "TestAUserIII".

What is the deal?

Please respond to the group, but email is ok too, just switch the username
and domain name in the address.

Thanks,
Greg


 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      09-03-2003
Are any Memo fields involved? This sounds like the bug described here:
http://www.aspfaq.com/show.asp?id=2188

Greg Hurlman wrote:
> I've got what I'm sure is a very simple problem. In an ASP page, I am
> trying to write out 4 fields from a recordset in succession:
>
> Response.Write rs("LastName")
> Response.Write rs("Suffix")
> Response.Write rs("FirstName")
> Response.Write rs("MiddleInitial")
>
> All fields are populated and are single terms. I would expect
> "LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test
> record) to be written out on the page. However, all I get is
> "LastNameSuffix" (UserIII). If I move the FirstName and/or
> MiddleInitial to be written first, I get "TestAUserIII".
>
> What is the deal?
>
> Please respond to the group, but email is ok too, just switch the
> username and domain name in the address.
>
> Thanks,
> Greg



 
Reply With Quote
 
 
 
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      09-03-2003
Show your code.


"Greg Hurlman" <> wrote in message
news:el#...
> I've got what I'm sure is a very simple problem. In an ASP page, I am

trying
> to write out 4 fields from a recordset in succession:
>
> Response.Write rs("LastName")
> Response.Write rs("Suffix")
> Response.Write rs("FirstName")
> Response.Write rs("MiddleInitial")
>
> All fields are populated and are single terms. I would expect
> "LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test record)

to
> be written out on the page. However, all I get is "LastNameSuffix"
> (UserIII). If I move the FirstName and/or MiddleInitial to be written
> first, I get "TestAUserIII".
>
> What is the deal?
>
> Please respond to the group, but email is ok too, just switch the username
> and domain name in the address.
>
> Thanks,
> Greg
>
>



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      09-03-2003
What's in your View-Source?

Also, try

Response.Write Server.HTMLEncode(rs.Fields.Item(0).Value)
Response.Write Server.HTMLEncode(rs.Fields.Item(1).Value)
Response.Write Server.HTMLEncode(rs.Fields.Item(2).Value)
Response.Write Server.HTMLEncode(rs.Fields.Item(3).Value)

What does that yield?

Ray at work




"Greg Hurlman" <> wrote in message
news:el%...
> I've got what I'm sure is a very simple problem. In an ASP page, I am

trying
> to write out 4 fields from a recordset in succession:
>
> Response.Write rs("LastName")
> Response.Write rs("Suffix")
> Response.Write rs("FirstName")
> Response.Write rs("MiddleInitial")
>
> All fields are populated and are single terms. I would expect
> "LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test record)

to
> be written out on the page. However, all I get is "LastNameSuffix"
> (UserIII). If I move the FirstName and/or MiddleInitial to be written
> first, I get "TestAUserIII".
>
> What is the deal?
>
> Please respond to the group, but email is ok too, just switch the username
> and domain name in the address.
>
> Thanks,
> Greg
>
>



 
Reply With Quote
 
Greg Hurlman
Guest
Posts: n/a
 
      09-03-2003
This yields the same result.

Also, from my View->Source...

<td>
UserIII
</td>

Where User is LastName, and III is Suffix.

Thanks,
Greg

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%...
> What's in your View-Source?
>
> Also, try
>
> Response.Write Server.HTMLEncode(rs.Fields.Item(0).Value)
> Response.Write Server.HTMLEncode(rs.Fields.Item(1).Value)
> Response.Write Server.HTMLEncode(rs.Fields.Item(2).Value)
> Response.Write Server.HTMLEncode(rs.Fields.Item(3).Value)
>
> What does that yield?
>
> Ray at work
>
>
>
>
> "Greg Hurlman" <> wrote in message
> news:el%...
> > I've got what I'm sure is a very simple problem. In an ASP page, I am

> trying
> > to write out 4 fields from a recordset in succession:
> >
> > Response.Write rs("LastName")
> > Response.Write rs("Suffix")
> > Response.Write rs("FirstName")
> > Response.Write rs("MiddleInitial")
> >
> > All fields are populated and are single terms. I would expect
> > "LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test

record)
> to
> > be written out on the page. However, all I get is "LastNameSuffix"
> > (UserIII). If I move the FirstName and/or MiddleInitial to be written
> > first, I get "TestAUserIII".
> >
> > What is the deal?
> >
> > Please respond to the group, but email is ok too, just switch the

username
> > and domain name in the address.
> >
> > Thanks,
> > Greg
> >
> >

>
>



 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      09-03-2003
Create a page with just the following server-side code in it (no html
stuff). Run it and let us know if you get the same result.

Bob

Greg Hurlman wrote:
> My code:
>
> Option Explicit
> Response.Buffer = True
>
> Dim rs, ID, SQL, cn, UserID
>
> Set cn = Server.CreateObject("ADODB.Connection")
> cn.Open Application("DSN")
> SQL = "select * from RegisteredUsers where UserID='" & UserID & "'"
> Set rs = cn.Execute(SQL)
>
> Response.Write rs("FirstName")
> Response.Write rs("LastName")
> Response.Write rs("Suffix")
> Response.Write rs("MiddleInitial")
> ...
>
> I've left out HTML formatting code, but the code above represents all
> DB interaction.
>
> Thanks,
> Greg
>
>
> "Aaron Bertrand - MVP" <> wrote in message
> news:...
>> Show your code.
>>
>>
>> "Greg Hurlman" <> wrote in message
>> news:el#...
>>> I've got what I'm sure is a very simple problem. In an ASP page, I
>>> am trying to write out 4 fields from a recordset in succession:
>>>
>>> Response.Write rs("LastName")
>>> Response.Write rs("Suffix")
>>> Response.Write rs("FirstName")
>>> Response.Write rs("MiddleInitial")
>>>
>>> All fields are populated and are single terms. I would expect
>>> "LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test
>>> record) to be written out on the page. However, all I get is
>>> "LastNameSuffix" (UserIII). If I move the FirstName and/or
>>> MiddleInitial to be written first, I get "TestAUserIII".
>>>
>>> What is the deal?
>>>
>>> Please respond to the group, but email is ok too, just switch the
>>> username and domain name in the address.
>>>
>>> Thanks,
>>> Greg



 
Reply With Quote
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      09-03-2003
Okay, now try:

<%
set conn = CreateObject("ADODB.Connection")
conn.open "<use a connection string from http://www.aspfaq.com/2126, not
an ODBC DSN>"
sql = "SELECT FirstName, LastName, Suffix, MiddleInitial" & _
" FROM RegisteredUsers WHERE UserID = '" & UserID & "'"
response.write sql & "<p>"
set rs = conn.execute(sql)
if not rs.eof then
response.write rs("FirstName") & "<br>"
response.write rs("LastName") & "<br>"
response.write rs("Suffix") & "<br>"
response.write rs("MiddleInitial") & "<br>"
else
response.write "Empty RS"
end if
rs.close: set rs = nothing
conn.close: set conn = nothing
%>

Key changes: (a) use an OLE-DB connection string, not a crappy DSN, (b)
*NAME* your columns, instead of lazy SELECT *, (c) test for EOF, (d) inspect
the actual SQL statement you're running (I don't see where you populate
UserID in your script).

Also, if UserID is a string, it is poorly named, IMHO. Appended "ID"
usually indicates a numeric column. If UserID is in fact a number, then
remove the single quotes around it.



"Greg Hurlman" <> wrote in message
news:...
> My code:
>
> Option Explicit
> Response.Buffer = True
>
> Dim rs, ID, SQL, cn, UserID
>
> Set cn = Server.CreateObject("ADODB.Connection")
> cn.Open Application("DSN")
> SQL = "select * from RegisteredUsers where UserID='" & UserID & "'"
> Set rs = cn.Execute(SQL)
>
> Response.Write rs("FirstName")
> Response.Write rs("LastName")
> Response.Write rs("Suffix")
> Response.Write rs("MiddleInitial")
> ...
>
> I've left out HTML formatting code, but the code above represents all DB
> interaction.
>
> Thanks,
> Greg
>
>
> "Aaron Bertrand - MVP" <> wrote in message
> news:...
> > Show your code.
> >
> >
> > "Greg Hurlman" <> wrote in message
> > news:el#...
> > > I've got what I'm sure is a very simple problem. In an ASP page, I am

> > trying
> > > to write out 4 fields from a recordset in succession:
> > >
> > > Response.Write rs("LastName")
> > > Response.Write rs("Suffix")
> > > Response.Write rs("FirstName")
> > > Response.Write rs("MiddleInitial")
> > >
> > > All fields are populated and are single terms. I would expect
> > > "LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test

> record)
> > to
> > > be written out on the page. However, all I get is "LastNameSuffix"
> > > (UserIII). If I move the FirstName and/or MiddleInitial to be written
> > > first, I get "TestAUserIII".
> > >
> > > What is the deal?
> > >
> > > Please respond to the group, but email is ok too, just switch the

> username
> > > and domain name in the address.
> > >
> > > Thanks,
> > > Greg
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Greg Hurlman
Guest
Posts: n/a
 
      09-03-2003
I implemented these changes one at a time, and moving from a DSN to a
connection string seems to have done the trick... in hindsight, this is
exactly the punishment the ASP gods should have given me for ignoring my
better judgement re: dsn after inheriting an old application.

Thanks for your help,
Greg

"Aaron Bertrand - MVP" <> wrote in message
news:%...
> Okay, now try:
>
> <%
> set conn = CreateObject("ADODB.Connection")
> conn.open "<use a connection string from http://www.aspfaq.com/2126,

not
> an ODBC DSN>"
> sql = "SELECT FirstName, LastName, Suffix, MiddleInitial" & _
> " FROM RegisteredUsers WHERE UserID = '" & UserID & "'"
> response.write sql & "<p>"
> set rs = conn.execute(sql)
> if not rs.eof then
> response.write rs("FirstName") & "<br>"
> response.write rs("LastName") & "<br>"
> response.write rs("Suffix") & "<br>"
> response.write rs("MiddleInitial") & "<br>"
> else
> response.write "Empty RS"
> end if
> rs.close: set rs = nothing
> conn.close: set conn = nothing
> %>
>
> Key changes: (a) use an OLE-DB connection string, not a crappy DSN, (b)
> *NAME* your columns, instead of lazy SELECT *, (c) test for EOF, (d)

inspect
> the actual SQL statement you're running (I don't see where you populate
> UserID in your script).
>
> Also, if UserID is a string, it is poorly named, IMHO. Appended "ID"
> usually indicates a numeric column. If UserID is in fact a number, then
> remove the single quotes around it.
>
>
>
> "Greg Hurlman" <> wrote in message
> news:...
> > My code:
> >
> > Option Explicit
> > Response.Buffer = True
> >
> > Dim rs, ID, SQL, cn, UserID
> >
> > Set cn = Server.CreateObject("ADODB.Connection")
> > cn.Open Application("DSN")
> > SQL = "select * from RegisteredUsers where UserID='" & UserID & "'"
> > Set rs = cn.Execute(SQL)
> >
> > Response.Write rs("FirstName")
> > Response.Write rs("LastName")
> > Response.Write rs("Suffix")
> > Response.Write rs("MiddleInitial")
> > ...
> >
> > I've left out HTML formatting code, but the code above represents all DB
> > interaction.
> >
> > Thanks,
> > Greg
> >
> >
> > "Aaron Bertrand - MVP" <> wrote in message
> > news:...
> > > Show your code.
> > >
> > >
> > > "Greg Hurlman" <> wrote in message
> > > news:el#...
> > > > I've got what I'm sure is a very simple problem. In an ASP page, I

am
> > > trying
> > > > to write out 4 fields from a recordset in succession:
> > > >
> > > > Response.Write rs("LastName")
> > > > Response.Write rs("Suffix")
> > > > Response.Write rs("FirstName")
> > > > Response.Write rs("MiddleInitial")
> > > >
> > > > All fields are populated and are single terms. I would expect
> > > > "LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test

> > record)
> > > to
> > > > be written out on the page. However, all I get is "LastNameSuffix"
> > > > (UserIII). If I move the FirstName and/or MiddleInitial to be

written
> > > > first, I get "TestAUserIII".
> > > >
> > > > What is the deal?
> > > >
> > > > Please respond to the group, but email is ok too, just switch the

> > username
> > > > and domain name in the address.
> > > >
> > > > Thanks,
> > > > Greg
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
recordset data getting truncted during response.write cbtechlists@gmail.com ASP General 3 01-23-2007 04:25 PM
Passing Recordset from an ASP page to another HTML page ? Oscar ASP General 27 06-01-2005 04:24 PM
Asp to Aspx, Response.Write Recordset.fields(1).value question Gian Paolo Clarici ASP .Net 0 07-21-2004 12:14 PM
Response.write RecordSet values Fawke101 ASP General 4 04-21-2004 04:38 PM
RecordSet.Move or RecordSet.AbsolutePosition?? Hung Huynh ASP General 8 09-24-2003 11:07 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57