|
-
Jul 13th, 2000, 05:20 PM
#1
Thread Starter
Hyperactive Member
Using asp, how would I set the array to display every row, but only columns 1, 3, and 6? I want the database to store all fields, but the display page should show only these few fields. Thanks for any help.
Here is my code I already have, it shows all fields which isn't what I need. Please help.
Code:
<%
Dim cnn
Dim rst
Dim connectString
set cnn = Server.CreateObject ("ADODB.Connection")
set rst = Server.CreateObject ("ADODB.Recordset")
ConnectString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\shared webs\art\new1\mdb\speed.mdb"
cnn.open connectString
rst.open "speed", cnn, 2, 2
%>
<Table Border="1" width="100%">
<tr bgcolor="#C0C0C0">
<%
if rst.EOF AND rst.BOF then
Response.Write ( "No Records found")
else
'output field names
For intFieldCounter = 0 To (rst.Fields.Count) - 1
Response.Write( "<TH>" & rst.Fields.Item(intFieldCounter).Name )
Next
Response.Write ( "</TR>" )
'output records
Do Until rst.EOF
Response.Write( "<TR>" )
for intFieldCounter = 0 to (rst.Fields.Count) - 1
if rst.Fields.Item(intFieldCounter).Name = "DonorID" then
Response.Write( "<TD> <A HREF=http://" & strServerName & "/dacm/content/donorTests.asp?DonorID=" & rst(intFieldCounter) & ">" & rst(intFieldCounter) & " </a> </TD>" )
else
Response.Write( "<TD>" & rst(intFieldCounter) & "</TD>" )
end if
Next
rst.MoveNext
Response.Write( "</TR>" )
Loop
Response.Write( "</Table>" )
rst.Close
cnn.Close
set cnn = Nothing
End if
%>
If you think education is expensive, try ignorance.
-
Jul 14th, 2000, 02:26 AM
#2
Fanatic Member
Hi artsapimp
To do what you ask, open your recordset using a SQL string.
Replace
rst.open "speed", cnn, 2, 2
With
rst.open "SELECT column1, column3, column6 From speed", cnn, 2, 2
repacing columnx with the names of your columns from the database
Hope this helps
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
Jul 14th, 2000, 09:12 AM
#3
Thread Starter
Hyperactive Member
Perfect, thank you very much.
How would I make the first column (ID) be a link to another page that shows all fields for the customer?
If you think education is expensive, try ignorance.
-
Jul 14th, 2000, 09:22 AM
#4
Fanatic Member
In your for loop do an If statement to see if the field number is the id column, and if it is put in an A tag but make the href = MYnewpage.asp?id=<% = rst(intFieldCounter) %>
Then in the new page use myid = request.querystring("id") to get the id.
Then when you open the recordset use "SELECT * FROM speed WHERE idcolumn = " & myid
if you Need any more help reply back
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
Jul 14th, 2000, 09:47 AM
#5
Thread Starter
Hyperactive Member
I got this error:
'800a0cc1'
ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application.
This is how I wrote the code, I'm sure it's wrong
[code]
If rst.Fields.Item(intFieldCounter).Name = "ID" Then
%>
<A href=edit.asp?id=<% = rst(intFieldCounter) %>><%= rst(intFieldCounter) %></A>
<%
End If
If you think education is expensive, try ignorance.
-
Jul 14th, 2000, 10:02 AM
#6
Fanatic Member
I cant see any error's
Which line are you getting it.
On the if statement or on the link line.
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
Jul 14th, 2000, 11:25 AM
#7
Thread Starter
Hyperactive Member
ADODB.Fields error '800a0cc1'
ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application.
/arthur/new1/mdb/test.asp, line 38
line 38:
Code:
If rst.Fields.Item(intFieldCounter).Name = "ID" Then
This is the whole code as of right now if that helps
Code:
<%
Dim cnn
Dim rst
Dim connectString
set cnn = Server.CreateObject ("ADODB.Connection")
set rst = Server.CreateObject ("ADODB.Recordset")
ConnectString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\shared webs\art\new1\mdb\speed.mdb"
cnn.open connectString
rst.open "SELECT ID, Location, Phone, ProvisionedSpeed, ActualSpeed, Status, NDCAgent From NDC", cnn, 2, 2
%>
<Table Border="1" width="100%">
<tr bgcolor="#C0C0C0">
<%
'output field names
For intFieldCounter = 0 To (rst.Fields.Count) - 1
Response.Write( "<TH>" & rst.Fields.Item(intFieldCounter).Name )
Next
Response.Write ( "</TR>" )
'output records
Do Until rst.EOF
Response.Write( "<TR>" )
for intFieldCounter = 0 to (rst.Fields.Count) - 1
Response.Write( "<TD>" & rst(intFieldCounter) & "</TD>" )
Next
rst.MoveNext
If rst.Fields.Item(intFieldCounter).Name = "ID" Then
%>
<A href=edit.asp?id=<% = rst(intFieldCounter) %>><%= rst(intFieldCounter) %></A>
<%
End If
Response.Write( "</TR>" )
Loop
Response.Write( "</Table>" )
rst.Close
cnn.Close
set cnn = Nothing
%>
If you think education is expensive, try ignorance.
-
Jul 17th, 2000, 03:17 AM
#8
Fanatic Member
Hi there again
still can't see what your problem if you replace the for loop with this
Code:
for intFieldCounter = 0 to (rst.Fields.Count) - 1
If intFieldCounter = 0 Then
%>
<TD><A href="edit.asp?id=<% = rst(intFieldCounter) %>"><%= rst(intFieldCounter) %></A></TD>
<%
else
Response.Write( "<TD>" & rst(intFieldCounter) & "</TD>" )
End If
Next
rst.MoveNext
You will get the desired affect
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
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
|
Click Here to Expand Forum to Full Width
|