How do I effectively show only one value from a ta

Results 1 to 2 of 2

Thread: How do I effectively show only one value from a ta

  1. #1
    Join Date
    Dec 1969

    Default How do I effectively show only one value from a ta

    I would like to know how to effectively only display one value from a table if multiple identical values exist. The following is an explanation of my program and its code:<BR><BR>In the database used for this program there are many numerical values for CategoryA in Table1 (variables CategoryA and Table1, respectively). Also in Table1 are many numerical values for CategoryB (variable categoryB). The values in categoryB are also held in Table2 as well as their 2 names, variables name1 and name2. This code gets the CategoryA value through a query string and selects only those values. Then it looks at the values remaining in CategoryB that link up with CategoryA after CategoryA has been limited to only 1 value. The same values in CategoryB are then found in Table2 and there two names are returned (name1 and name2). The key to this code is that although there may be many values in CategoryB that are the same each name is only output once so an identical name is not displayed to the user. Everything works ok; each name is only displayed once but, at the end of the code I get the following error: <BR>error &#039;80020009&#039;<BR>Exception occurred. <BR>/code.asp, <BR>line xx (see code for line) <BR>Could someone please look through this code and write a possible solution to this error or tell me a more effective way to display name1 and name2 only once. Your help is greatly appreciated. I am afraid that my beginning ASP skills have failed me.<BR><BR>&#039;database connection<BR>DIM db<BR>set db= server.createobject("ADODB.Connection")<BR> "database", adOpenForwardOnly, adCmdTable<BR><BR>&#039;Get the value that will be filtered for CategoryA from Table1<BR>Dim CategoryA<BR>CategoryA = Request.QueryString("CategoryA")<BR><BR>&#039;Sele ct only the one value from CategoryA and open connection<BR>Dim SQL, SQL2<BR>Sql = "SELECT * FROM Table1 WHERE CategoryA = &#039;" & CategoryA & "&#039; ORDER BY CategoryB DESC;"<BR>Dim rsVar1<BR>set rsVar1 = Server.createObject("ADODB.Recordset")<BR>rsReview .open mySQL, db2<BR><BR>&#039;The following lines of code go to Table2 and find the corresponding values of CategoryB with that of Table1 CategoryB and writes out the 2 names.<BR>DO WHILE NOT rsReview.EOF <BR>CategoryB = rsVar1("CategoryB")<BR>Sql2 = "SELECT * FROM Table2 WHERE CategoryB = &#039;" & CategoryB & "&#039; ORDER BY Name1 DESC;"<BR>Dim rsVar2<BR>set rsVar2 = Server.createObject("ADODB.Recordset")<BR>rsCourse .open SQL2, db<BR>response.write rsVar2("Name1")<BR>response.write rsVar2("Name2")<BR>rsVar1.MoveNext<BR><BR>&#039;Th is is the key to the program, the following makes sure that identical values are not shown or else it will skip to the next record<BR>IF rsVar1("CategoryB") = CategoryB THEN<BR>&#039;The next line is where the error occurs<BR>DO WHILE NOT rsReview("CategoryB") &#060;&#062; CategoryB <BR>rsVar1.MoveNext<BR>LOOP<BR>ELSE<BR>END IF<BR>LOOP<BR>

  2. #2
    Join Date
    Dec 1969

    Default ** crosspost **


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts