|
 |
asp_databases thread: Somebody Please Help me out, Im stuck
Message #1 by "Mitten" <mittenshah@h...> on Fri, 24 Aug 2001 21:38:50
|
|
I have a problem with displaying data from the database, can anyone please
help me spot where i've gone wrong. This is how i want my data to be
displayed:
Authors: Steeve Summers, Tom Spencer
Title: Management
Year: 2000
But i get my data displayed like this:
Authors :Steeve, Summers
Title : Management, &
Year : 2001
Tom, Spencer
Here is my code:
<%
Dim objRS, objRS1,objComm,objComm1, objParam,objParam1,
strJournal,strJournal1,varDropBox
Dim sTmp
Dim sPrevTitle
Dim sPrevYear
varDropBox = Request.Form("style")
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = strConnect
objComm.CommandText = "searchJournal"
objComm.CommandType = adCmdStoredProc
Set objParam =_
objComm.CreateParameter("Required Journal",adVarChar,adParamInput,50)
objComm.Parameters.Append objParam
strJournal = Request.Form("Journal")
objComm.Parameters("Required Journal") = strJournal
Set objRS = objComm.Execute
'Response.Write "<h1>Journal Articles by " & strJournal & "<br>"
While Not objRS.EOF
Select Case varDropBox
Case "normal"
'Response.Write "Authors : "
if left(stmp, 10) = "Authors : " then
stmp = "Authors : "
end if
stmp = stmp & objRS("FName") & "," & " " &_
objRS("LName") &"<br>"
'Response.Write "Title : "
if sPrevTitle = objRS("Title") then
else
stmp = stmp & vbcrlf & "Title : "
stmp = stmp & objRS("Title") & "," & " " & "&<br>"
sPrevTitle = objRS("Title")
end if
'Response.Write "Year : "
if sPrevYear = objRS("Year") then
'you already have this year - dont reprint it
else
stmp = stmp & "Year : "
stmp = stmp & objRS("Year")& "<br>"
sPrevYear = objRS("Year")
end if
End Select
objRS.MoveNext
Wend
Response.Write stmp
%>
Message #2 by Kyle Burns <kburns@c...> on Fri, 24 Aug 2001 16:53:42 -0500
|
|
It looks like you should be storing your data in several temporary
strings
before building your display string. Try something like this:
<SNIP>
<%
Dim sAuthorList
Dim sTitleList
Dim sYearList
Do Until objRS.EOF
'Build Author List
sAuthorList =3D sAuthorList & objRS("FName") & " " & objRS("LName")
& ", "
'Build Title List
If sPrevTitle =3D objRS("title") Then
'Don't do anything
Else
sTitleList =3D sTitleList & objRS("title") & ", "
sPrevTitle =3D objRS("title")
End If
'Build Year List
If sPrevYear =3D objRS("year") Then
'Don't do anything
Else
sYearList =3D sYearList & objRS("year") & ", "
sPrevYear =3D objRS("year")
End If
objRS.MoveNext
Loop
'Cut off trailing commas (don't forget the space)
sAuthorList =3D Left(sAuthorList, Len(sAuthorList) - 2)
sTitleList =3D Left(sTitleList, Len(sTitleList) - 2)
sYearList =3D Left(sYearList, Len(sYearList) - 2)
'Now we can display the data
%>
Authors: <% =3DsAuthorList %><BR>
Title: <% =3DsTitleList %><BR>
Year: <% =3DsYearList %>
</SNIP>
This is just thrown together and may not be quite right, but it should
at
least get you started.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D
Kyle M. Burns, MCSD
ECommerce Technology Manager
Centra Credit Union
kburns@c...
Message #3 by "Mitten Shah" <mittenshah@h...> on Fri, 24 Aug 2001 23:44:06 +0100
|
|
Hi Kyle, I really appreciate for helping me out, it kinda worked but with a
small hitch. Well my output is something like this
Authors: Steeve Summers, Peter Smith
Title: Management, Strategy
Year: 2001, 2000
But it is merging two article titles, authors and Year in one heading.
I would like something like this
Authors: Steeve Summers,Peter Smith
Title: Management
Year: 2001
And i want something like this:
Authors: Peter Saunders
Title: Strategy
Year: 2000
This is the only problem that is remaining, i really appreciate your help.
Please tell me what can i do.
Thanks
----- Original Message -----
From: Kyle Burns <kburns@c...>
To: ASP Databases <asp_databases@p...>
Sent: Friday, August 24, 2001 10:53 PM
Subject: [asp_databases] RE: Somebody Please Help me out, Im stuck
It looks like you should be storing your data in several temporary strings
before building your display string. Try something like this:
<SNIP>
<%
Dim sAuthorList
Dim sTitleList
Dim sYearList
Do Until objRS.EOF
'Build Author List
sAuthorList = sAuthorList & objRS("FName") & " " & objRS("LName")
& ", "
'Build Title List
If sPrevTitle = objRS("title") Then
'Don't do anything
Else
sTitleList = sTitleList & objRS("title") & ", "
sPrevTitle = objRS("title")
End If
'Build Year List
If sPrevYear = objRS("year") Then
'Don't do anything
Else
sYearList = sYearList & objRS("year") & ", "
sPrevYear = objRS("year")
End If
objRS.MoveNext
Loop
'Cut off trailing commas (don't forget the space)
sAuthorList = Left(sAuthorList, Len(sAuthorList) - 2)
sTitleList = Left(sTitleList, Len(sTitleList) - 2)
sYearList = Left(sYearList, Len(sYearList) - 2)
'Now we can display the data
%>
Authors: <% =sAuthorList %><BR>
Title: <% =sTitleList %><BR>
Year: <% =sYearList %>
</SNIP>
This is just thrown together and may not be quite right, but it should at
least get you started.
=================================
Kyle M. Burns, MCSD
ECommerce Technology Manager
Centra Credit Union
kburns@c...
Message #4 by Kyle Burns <kburns@c...> on Mon, 27 Aug 2001 06:56:46 -0500
|
|
It's the old Control-Break reporting. Do exactly what I showed you in
the
previous example except before the loop begins, set a variable called
sPrevTitle equal to objRS("title"). Before you start setting all the
variables within the loop, check to see if sPrevTitle =3D
objRS("title"). If
not, write out the output that you've gathered so far and the reset all
your
variables to vbNullString.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D
Kyle M. Burns, MCSD
ECommerce Technology Manager
Centra Credit Union
kburns@c...
-----Original Message-----
From: Mitten Shah [mailto:mittenshah@h...]
Sent: Friday, August 24, 2001 5:44 PM
To: ASP Databases
Subject: [asp_databases] RE: Somebody Please Help me out, Im stuck
Hi Kyle, I really appreciate for helping me out, it kinda worked but
with a
small hitch. Well my output is something like this
Authors: Steeve Summers, Peter Smith
Title: Management, Strategy
Year: 2001, 2000
But it is merging two article titles, authors and Year in one heading.
I would like something like this
Authors: Steeve Summers,Peter Smith
Title: Management
Year: 2001
And i want something like this:
Authors: Peter Saunders
Title: Strategy
Year: 2000
This is the only problem that is remaining, i really appreciate your
help.
Please tell me what can i do.
Thanks
----- Original Message -----
From: Kyle Burns <kburns@c...>
To: ASP Databases <asp_databases@p...>
Sent: Friday, August 24, 2001 10:53 PM
Subject: [asp_databases] RE: Somebody Please Help me out, Im stuck
It looks like you should be storing your data in several temporary
strings
before building your display string. Try something like this:
<SNIP>
<%
Dim sAuthorList
Dim sTitleList
Dim sYearList
Do Until objRS.EOF
'Build Author List
sAuthorList =3D sAuthorList & objRS("FName") & " " & objRS("LName")
& ", "
'Build Title List
If sPrevTitle =3D objRS("title") Then
'Don't do anything
Else
sTitleList =3D sTitleList & objRS("title") & ", "
sPrevTitle =3D objRS("title")
End If
'Build Year List
If sPrevYear =3D objRS("year") Then
'Don't do anything
Else
sYearList =3D sYearList & objRS("year") & ", "
sPrevYear =3D objRS("year")
End If
objRS.MoveNext
Loop
'Cut off trailing commas (don't forget the space)
sAuthorList =3D Left(sAuthorList, Len(sAuthorList) - 2)
sTitleList =3D Left(sTitleList, Len(sTitleList) - 2)
sYearList =3D Left(sYearList, Len(sYearList) - 2)
'Now we can display the data
%>
Authors: <% =3DsAuthorList %><BR>
Title: <% =3DsTitleList %><BR>
Year: <% =3DsYearList %>
</SNIP>
This is just thrown together and may not be quite right, but it should
at
least get you started.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D
Kyle M. Burns, MCSD
ECommerce Technology Manager
Centra Credit Union
kburns@c...
|
|
 |