How to limit columns using ASP (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Guest -> How to limit columns using ASP (3/9/2001 20:40:00)

I am creating a web page using asp, not DRW, and my result show every column. How can I limit the results to only the columns that I want to show?




Spooky -> RE: How to limit columns using ASP (3/9/2001 14:32:00)

In your SQL query, you restrict the data returned to only that required.

So instead of "Select * from" you would "select column1,column2 from"

Now when you display the data, instead of using html (and the database result) to display every column, you only show those from the record set.

Do you have a code you are using?

------------------
Spooky
"I am Spooky of Borg. Prepare to be assimilated, babycakes!"
Subscribe to OutFront News
Database / DRW Q & A
The Spooky Login!





Guest -> RE: How to limit columns using ASP (3/9/2001 15:25:00)

Here is the code that I am working with:

<FORM action="2726-09-RSMeth-TIO-05-DeleteConfirm.asp" method=POST id=form1 name=form1>
Class Name <input type=text name="ClassName">
<input type=submit>
</FORM>

<%
'Read list to user (this could be done in a list box)
dim oRS
set oRS=server.CreateObject("adodb.recordset")
oRS.Open "BoatClass", "DSN=Sailors",adOpenDynamic,adLockBatchOptimistic
Response.Write "List of all classes"
Response.Write "<table border=1><TR>"
Response.Write "<th>ID</th><th>Name</th><th>Length</th>"
Response.Write "<th>Weight</th><th>Date Entered</th>"
Response.Write "</tr><td>"
Response.write oRS.GetString(adClipString,,"</td><td>","</td></tr><tr><td>"," ")
Response.Write "<table border=1>"
Response.Write "</table></TD></TR>"
%>





Spooky -> RE: How to limit columns using ASP (3/9/2001 16:08:00)

Ahh.. WROX Begining databases huh?

Try :
sSQL = "Select [column],[column] from BoatClass"
set oRS=server.CreateObject("adodb.recordset")
oRS.Open sSQL , "DSN=Sailors",adOpenDynamic,adLockBatchOptimistic

etc

With getstring, unless you want to format the rows differently (or use getrows) you only ask for the column names you need in the SQL string.

The previous database call, was opening the table and returning all reults.

If you specify the [column name] in the SQL string, itll only return those columns.

You then neednt worry about the display line:
Response.write oRS.GetString(adClipString,,"</td><td>","</td></tr><tr><td>"," ")

------------------
Spooky
"I am Spooky of Borg. Prepare to be assimilated, babycakes!"
Subscribe to OutFront News
Database / DRW Q & A
The Spooky Login!





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
4.589844E-02