A
Arpan
A Form has a select list which lists all the column names of a SQL
Server database table. Users will select one or more than one column
from this select list & after submitting the Form, the records of only
those columns that he had selected in the previous page will be
displayed to him. This is the Form code:
----------------------------------------
strSQL="SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME='tblSheet' ORDER BY ORDINAL_POSITION"
..............
..............
objRS.Open strSQL,objConn
<form........>
<select name="colname" multiple size=5>
Do Until(objRS.EOF)
%>
<option><%= objRS("COLUMN_NAME") %></option>
<%
objRS.MoveNext
Loop
%>
</select>
----------------------------------------
& this is the ASP page that retrieves the records:
----------------------------------------
<%
Dim strColNames,arrColName,strEachColName
strColNames=Request.Form("colname")
arrColName=Split(strColNames,", ")
.............
.............
.............
Dim strSQL
strSQL="SELECT " & strColNames & " FROM tblSheet"
.............
.............
.............
objRS.Open strSQL,objConn
%>
<table border=2>
<tr>
<%
For Each strEachColName In arrColName
%>
<th><%= strEachColName %></th>
<%
Next
%>
</tr>
<%
Do Until(objRS.EOF)
%>
<tr>
----------------------------------------
Now how do I loop through the recordset to display the recordset to the
user? Had the column names not been generated dynamically,
objRS("ColumnName") would have sufficed but how do I do the same here?
Thanks,
Arpan
Server database table. Users will select one or more than one column
from this select list & after submitting the Form, the records of only
those columns that he had selected in the previous page will be
displayed to him. This is the Form code:
----------------------------------------
strSQL="SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME='tblSheet' ORDER BY ORDINAL_POSITION"
..............
..............
objRS.Open strSQL,objConn
<form........>
<select name="colname" multiple size=5>
Do Until(objRS.EOF)
%>
<option><%= objRS("COLUMN_NAME") %></option>
<%
objRS.MoveNext
Loop
%>
</select>
----------------------------------------
& this is the ASP page that retrieves the records:
----------------------------------------
<%
Dim strColNames,arrColName,strEachColName
strColNames=Request.Form("colname")
arrColName=Split(strColNames,", ")
.............
.............
.............
Dim strSQL
strSQL="SELECT " & strColNames & " FROM tblSheet"
.............
.............
.............
objRS.Open strSQL,objConn
%>
<table border=2>
<tr>
<%
For Each strEachColName In arrColName
%>
<th><%= strEachColName %></th>
<%
Next
%>
</tr>
<%
Do Until(objRS.EOF)
%>
<tr>
----------------------------------------
Now how do I loop through the recordset to display the recordset to the
user? Had the column names not been generated dynamically,
objRS("ColumnName") would have sufficed but how do I do the same here?
Thanks,
Arpan