469,602 Members | 1,984 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Recordset elements failing to write to page

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
Jul 19 '05 #1
10 2714
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

Jul 19 '05 #2
Sadly, no... the field definitions are these (from a SQL 2000 DB):

FirstName - varchar 50
MiddleInitial - char 1
LastName - varchar 50
Suffix - varchar 10

Thanks,
Greg

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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


Jul 19 '05 #3
Show your code.
"Greg Hurlman" <sq*******@ghurlman.net> wrote in message
news:el*************@TK2MSFTNGP12.phx.gbl...
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

Jul 19 '05 #4
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" <sq*******@ghurlman.net> wrote in message
news:el***************@TK2MSFTNGP12.phx.gbl...
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

Jul 19 '05 #5
you're not using any conditional statements or trying to write out the
recordset data more than once?
could be your choice of recordset cursor

jason

"Greg Hurlman" <sq*******@ghurlman.net> wrote in message
news:uw**************@TK2MSFTNGP11.phx.gbl...
Sadly, no... the field definitions are these (from a SQL 2000 DB):

FirstName - varchar 50
MiddleInitial - char 1
LastName - varchar 50
Suffix - varchar 10

Thanks,
Greg

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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



Jul 19 '05 #6
You're going to have to give us more to go on. Show us the connection string
for your connection object (censor the user info of course) and the code
used to open your recordset.

Are you using ODBC or the native SQL OLEDB provider (recommended)?

FWIW, I've never experienced this problem.

Bob Barrows

Greg Hurlman wrote:
Sadly, no... the field definitions are these (from a SQL 2000 DB):

FirstName - varchar 50
MiddleInitial - char 1
LastName - varchar 50
Suffix - varchar 10

Thanks,
Greg

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Jul 19 '05 #7
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:%2****************@TK2MSFTNGP12.phx.gbl...
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" <sq*******@ghurlman.net> wrote in message
news:el***************@TK2MSFTNGP12.phx.gbl...
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


Jul 19 '05 #8
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" <aa***@TRASHaspfaq.com> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
Show your code.
"Greg Hurlman" <sq*******@ghurlman.net> wrote in message
news:el*************@TK2MSFTNGP12.phx.gbl...
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

Jul 19 '05 #9
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" <sq*******@ghurlman.net> wrote in message
news:e2**************@tk2msftngp13.phx.gbl...
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" <aa***@TRASHaspfaq.com> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
Show your code.
"Greg Hurlman" <sq*******@ghurlman.net> wrote in message
news:el*************@TK2MSFTNGP12.phx.gbl...
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



Jul 19 '05 #10
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" <aa***@TRASHaspfaq.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <sq*******@ghurlman.net> wrote in message
news:e2**************@tk2msftngp13.phx.gbl...
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" <aa***@TRASHaspfaq.com> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
Show your code.
"Greg Hurlman" <sq*******@ghurlman.net> wrote in message
news:el*************@TK2MSFTNGP12.phx.gbl...
> 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
>
>



Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by Rob Meade | last post: by
5 posts views Thread by slowmotiongenius | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.