Problem Code !

Results 1 to 4 of 4

Thread: Problem Code !

  1. #1
    Chris Chang Guest

    Default Problem Code !

    Please could someone let me know what is wrong with this bit of code, it all works fine and returns the correct number of records into the Dropdown, BUT all the records displayed are the same as the 1st one in the list ! Here is the code is anyone can help.<BR><BR>&#060;html&#062;<BR><BR>&#060;head&#0 62;<BR>&#060;title&#062;Droptest&#060;/title&#062;<BR>&#060;/head&#062;<BR>&#060;body&#062;<BR><BR>&#060;%<BR>v tables = Array("test")<BR>vfields = Array("OUC")<BR>vcaption = Array("Another OUC")<BR><BR> dbConnect="DSN=test" <BR>%&#062;<BR><BR>&#060;table&#062;<BR>&#060;tr&# 062;<BR>&#060;td&#062; Test drop down Population! &#060;/td&#062;<BR><BR>&#060;td&#062;&#060;form method="get" action="droptestoutput.asp"&#062;&#060;/td&#062;<BR>&#060;/tr&#062;<BR><BR>&#060;% <BR> Set rstemp = Server.createObject("adodb.recordset")<BR>for i=0 to UBound(vtables)<BR><BR>mySQL = "SELECT DISTINCT " & vfields(i) & " FROM " & vtables(i) & " ORDER BY " & vfields(i) & ";"<BR> rstemp.Open mySQL, dbconnect, adopenstatic<BR>response.write("&#060;tr&#062;") <BR>tempreturn =rstemp(0)<BR>response.write("&#060;td&#062;")<BR> response.write(vcaption(i))<BR>response.write("&#0 60;/td&#062;")<BR>response.write("&#060;td&#062;")<BR> response.write("&#060;select name=""" & vfields(i) & """&#062;")<BR>While Not rstemp.EOF<BR><BR>myReturn = replace(tempreturn, "&#039","&#039&#039")<BR>response.write("&#060;opt ion value = """)<BR>response.write(myReturn)<BR>response.write (""" &#062;")<BR>response.write(myReturn)<BR>response.w rite("&#060;/option&#062;")<BR>rstemp.MoveNext<BR>Wend<BR>respo nse.write("&#060;/select&#062;")<BR>response.write("&#060;/td&#062;")<BR>response.write("&#060;/tr&#062;")<BR>rstemp.Close<BR><BR>Next<BR><BR>%&#0 62;<BR><BR>&#060;tr&#062;<BR>&#060;td&#062;&#060;i nput type="submit" value="Search"&#062;<BR>&#060;input type="reset" value=" Clear "&#062;&#060;/td&#062;<BR>&#060;/tr&#062;<BR>&#060;/table&#062;<BR><BR>&#060;%<BR>Set rstemp=Nothing<BR>Set dbConnect=Nothing<BR>%&#062;<BR>&#060;/body&#062;<BR>&#060;/html&#062;<BR>

  2. #2
    Sathiya Guest

    Default RE: Problem Code !

    I think this may be the problem<BR>tempreturn =rstemp(0)<BR>myReturn = replace(tempreturn, "&#039","&#039&#039")<BR>The above lines only get the first value and assign to myreturn.<BR>you r using for loop to change only the value of i not the myreturn.<BR><BR>While ------ .Eof<BR>response.write(myReturn)<BR>-------<BR>will print only the first value till it reaches EOF<BR><BR><BR><BR><BR><BR>

  3. #3
    Chris Chang Guest

    Default RE: Problem Code !(thanks)

    Cool, thanks for that, so If I set up a loop for Myreturn that should sort it out ?<BR>Is it possiable to attach it to the i loop ???<BR><BR>Thanks<BR><BR>CC

  4. #4
    Sathiya Guest

    Default RE: Problem Code !

    I will give a simple example this may help u<BR>sqlstr = select Name from table <BR>set rsName = connection.execute("sqlstr")<BR>----------------------<BR>( inside HTML code)<BR>&#060;select name=Name&#062;<BR>do while rsName.eof<BR> &#060;option value=&#060;%rsName("Name")%&#062;<BR> &#060;%rsName("Name")%&#062;<BR> &#060;/option&#062;<BR>&#060;%rsName.moveNext<BR>loop %&#062;<BR>&#060;/select&#062;<BR><BR>


Posting Permissions

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