-
Returns 1st value only from db !
The below code accesses a db, and populates some dropdowns with data, the
problem is that it only return the value
of the first record, even though it record the correct amount of records
( I.e. they are all the same number )
help !!!!!!
<%@ LANGUAGE="VBSCRIPT" %>
<%
Option Explicit
GetWeekListForComboBox()
Response.end
' --------------------------------------------------------
Function GetWeekListForComboBox()
' -- Declare Variables
Dim adopenstatic ' Our Connection Object
Dim rstemp ' Our Recordset Object
Dim mySQL ' Our SQL String to access the database
Dim dbconnect ' Our Connection string to access the database
Dim i ' a counter variable
Dim vtables ' Our Function Return Value
Dim vfields
Dim vcaption
Dim tempReturn
Dim myReturn
Dim J
vtables = Array("table1", "table2", "table3") ' Tables to use
vfields = Array("name", "bday", "age")
vcaption = Array("Name", "Birthday", "Age")
dbconnect = "DSN=shortcalls"
%>
<table border=1>
<tr>
<td>TEST Drop Down</td>
<td><form method="POST" action="post.asp"></td>
</tr>
<%
Set rstemp = Server.CreateObject("adodb.Recordset")
For i = 0 to Ubound(vfields)
mySQL = "SELECT DISTINCT " & vfields(i) & " FROM " & vtables(i) & " WHERE
" & vfields(i) & "<> NULL" & " ORDER BY " & vfields(i) & ";"
rstemp.Open mySQL, dbconnect, adopenstatic
response.write("<tr>")
tempReturn = rstemp(0)
response.write("<td>")
response.write(vcaption(i))
response.write("</td>")
response.write("<td>")
response.write("<select name = """ & vfields(i) & """>")
while Not rstemp.EOF
myReturn = replace(tempReturn, "'","''")
response.write("<option value= """)
response.write(myReturn)
response.write(""" >")
response.write(myReturn)
response.write("</option>")
rstemp.MoveNext
Wend
response.write("</select>")
response.write("</td>")
response.write("</tr>")
rstemp.close
Next
%>
<tr>
<td><input type="submit" value="Run Report">
<input type="reset" value="reset values"></td>
</tr>
</table>
<%
Set rstemp=Nothing
'dbconnect.Close
'Set dbconnect=Nothing
end function
%>
Thankyou
Paul
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks