Jump to content

Display Data from database


feti
 Share

Recommended Posts

I hope anyone can help me on this...i'm newbies in ASP...last 2 weeks just learn how ASP work with form accessing databaseI want to display certain fields of data in database for viewing, I created the code but its only display the first data in database, the rest I can't see it, I want to display out the rest of related data, anyone please help me to explain my coding problem....:)The code:If sGQDidentifier <> " " then sSQLEnc = sSQLEnc & "SELECT * FROM cfts_admin.ddts_enclosures_readonly WHERE identifier = '" & sGQDidentifier & "'" set rsEnc = Server.CreateObject("ADODB.Recordset") rsEnc.Open sSQLEnc,ddtsConnect if not rsEnc.EOF then Do While Not rsEnc.EOF sGQDEncName = rsEnc.Fields("name") rsEnc.movenext loop else response.write "end of file" end if fnCLDestroyObject(rsEnc) sGHTTemp = sGHTTemp & " <tr>" & vbCrLf & _ " <td colspan=2 width=100%_>" & vbCrLf & _ " <span class='issue-field-label'>Enclosure Records</span>" & vbCrLf & _ " <span class='issue-field-content'>: " & sGQDEncName & "</a>" & vbCrLf & _ " </span>" & vbCrLf & _ " </td>" & vbCrLf & _ " </tr>" & vbCrLf & _ "</table>" & vbCrLf end ifThe unsuccessfully display result:Enclosure Records : BINARY:EMEA_Summary.msg *It should display more than this...

Link to comment
Share on other sites

Thanx in reply,I cannot remove WHERE statement cause i need that,I need in querying where only the specific data will display whenever user login into this page they will be directed or viewing certain records to be seen, depends on theirs selection, so within this quiry form contain of Enclosures Table, it shoud contained more than 1 title to be displayed out, sometimes 1 records = i Identifier (ID), will have more than 1 enclosures, so I need to display those data. Please help me on this...

Link to comment
Share on other sites

i did my coding like this.then as long there is still data in the dbase it will display it.hope it work for you.i'm new too in asp.about 1 and half month.<%while not rs.EOF%>Response.Write("<TD>")Response.Write(rs("courses")& "</TD>")
The problem is that you use a variable to display your result. In the while loop you get the value, you assign that to the variable, then get the next, ovewrite the same variable with the new value and so on. So you only display the last value, right?Your solution would be to display the result in the while loop, something like this:Do While Not rsEnc.EOFsGQDEncName = rsEnc.Fields("name")sGHTTemp = sGHTTemp & " <tr>" & vbCrLf & _" <td colspan=2 width=100%_>" & vbCrLf & _" <span class='issue-field-label'>Enclosure Records</span>" & vbCrLf & _" <span class='issue-field-content'>: " & sGQDEncName & "</a>" & vbCrLf & _" </span>" & vbCrLf & _" </td>" & vbCrLf & _" </tr>" & vbCrLf & _"</table>" & vbCrLfrsEnc.movenext loopelseresponse.write "end of file"end iffnCLDestroyObject(rsEnc)Try this and let me know!
Link to comment
Share on other sites

The problem is that you use a variable to display your result. In the while loop you get the value, you assign that to the variable, then get the next, ovewrite the same variable with the new value and so on. So you only display the last value, right?Your solution would be to display the result in the while loop, something like this:Do While Not rsEnc.EOFsGQDEncName = rsEnc.Fields("name")sGHTTemp = sGHTTemp & " <tr>" & vbCrLf & _" <td colspan=2 width=100%_>" & vbCrLf & _" <span class='issue-field-label'>Enclosure Records</span>" & vbCrLf & _" <span class='issue-field-content'>: " & sGQDEncName & "</a>" & vbCrLf & _" </span>" & vbCrLf & _" </td>" & vbCrLf & _" </tr>" & vbCrLf & _"</table>" & vbCrLfrsEnc.movenext loopelseresponse.write "end of file"end iffnCLDestroyObject(rsEnc)Try this and let me know!
i've done it and it works
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...