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
> > >
> > >
> >
> >
>
>