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_SCH EMA.COLUMNS WHERE
TABLE_NAME='tbl Sheet' ORDER BY ORDINAL_POSITIO N"
..............
..............
objRS.Open strSQL,objConn
<form........ >
<select name="colname" multiple size=5>
Do Until(objRS.EOF )
%>
<option><%= objRS("COLUMN_N AME") %></option>
<%
objRS.MoveNext
Loop
%>
</select>
----------------------------------------
& this is the ASP page that retrieves the records:
----------------------------------------
<%
Dim strColNames,arr ColName,strEach ColName
strColNames=Req uest.Form("coln ame")
arrColName=Spli t(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("ColumnNa me") 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_SCH EMA.COLUMNS WHERE
TABLE_NAME='tbl Sheet' ORDER BY ORDINAL_POSITIO N"
..............
..............
objRS.Open strSQL,objConn
<form........ >
<select name="colname" multiple size=5>
Do Until(objRS.EOF )
%>
<option><%= objRS("COLUMN_N AME") %></option>
<%
objRS.MoveNext
Loop
%>
</select>
----------------------------------------
& this is the ASP page that retrieves the records:
----------------------------------------
<%
Dim strColNames,arr ColName,strEach ColName
strColNames=Req uest.Form("coln ame")
arrColName=Spli t(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("ColumnNa me") would have sufficed but how do I do the same here?
Thanks,
Arpan
Comment