Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
03-09-2011, 04:21 PM #1
- Join Date
- Mar 2011
- Thanked 0 Times in 0 Posts
New to ADO, having some problems.
Hi, i'm currently doing my final year project for university and I need to display a database on an html page, i decided to do it using ADODB. I've never used this before and i'm currently having some problems that i'm hoping someone will be able to help me with.
Here is the code in my .asp file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <link rel="stylesheet" href="rostercss.css" type="text/css" media="screen" /> <title>Roster</title> </head> <body> <div id="roster"> <!--roster div--> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.ACE.OLEDB.12.0" conn.Open "c:/inetpub/wwwroot/Roster.accdb" set rs = Server.CreateObject("ADODB.recordset") rs.Open "SELECT Number, FirstName, LastName FROM Roster", conn %> <table border="1" width="100%"> <tr> <%for each x in rs.Fields response.write("<th>" & x.name & "</th>") next%> </tr> <%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td><%Response.Write(x.value)%></td> <%next rs.MoveNext%> </tr> <%loop rs.close conn.close %> </table> </div> <!--end roster div--> </body> </html>
I have the .asp file on a uni drive which i'm accessing via VPN, and the database file is in C:\webdata\wwwroot. I have IIS turned on.
Please help i'ev been stuck on this for ages!
Thanks in advance!
03-10-2011, 07:44 PM #2
- Join Date
- Apr 2009
- Thanked 20 Times in 20 Posts
1. You are working with Legacy ASP and you posted in ASP.NET section. It doesn't matter to me, but you might get better responses if you post in the correct section.
2. The picture you posted is not visible.
3. Putting HTML tags inside Response.Write is a bad style. Don't do that. For example, you have
<%for each x in rs.Fields response.write("<th>" & x.name & "</th>") next%>
<%for each x in rs.Fields%> <th> <%=x.name%> </th> <%next%>
The point is, don't rush with the HTML stuff.