The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

oops

missunderstood your example! it appears to me that your telling the sql to select everything from the 2 table where the main-table and description-table are the same, correct? try the operator "Like" instead of "=". I have gotten that to work when "=" wouldn't...

Ohhh!! I see what you're trying to do now! <<slaps head a couple dozen times>>

Try something like this:

Code:

dim fieldsarray
fieldsarray = ""
strSQL = "SELECT * FROM MAIN_TABLE"
rs.Open strSQL, my_conn
if rs.EOF then
' No records
else
for i = 0 to (rs.fields.count - 1)
if i > 0 then
fieldsarray = fieldsarray & ","
end if
fieldsarray = fieldsarray & "'" & rs.fields(i).name & "'"
next
strSQL = "SELECT DESCRIPTION " & _
" FROM DESCRIPTION_TABLE " & _
" WHERE FIELD_NAME in (" & fieldsarray & ")"
' Note: You may need to play with this SQL statement to get the order you want. I did it with the array to only have one hit on the database. You could do it field by field.
rs2.Open strSQL, my_conn
Do until rs2.EOF
Response.Write "<th>" & rs2("DESCRIPTION") & "</th>"
rs2.movenext
loop
rs2.Close
do until rs.EOF
' Do the rest of your coding here.....

<disclaimer> This code has NOT been tested in anyway. It's just something to get you on your way....</disclaimer>