Hello eveyone,
I know this topic has been discussed quite a bit on this forum. I went through the examples but am still having some problems.
My output asp page has three images and an html table. I added the line at the top of the page to display the Excel page. I see the images overlapping the first row of the table (the column heading) but I don't see the actual records that are queried. It feels like the information is being displayed in the Excel Format before the recordset is entered.
Here's the code:
<%@ Language=VBScript %>
<%
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
%><html>
<head>
<title>View Ts</title>
</head>
<body bgcolor="white" text="black">
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim t
Dim size
Dim depat
Dim department
depat = Request.Form("department")
Response.write(depat)
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("t.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"
'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT TDetails.* FROM TDetails;"
'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon
%>
<br>
<br>
<br>
<br>
<br>
<table>
<tr>
<font face="arial, helvetica" color="#000066" size="2"><b>View Ts</b></font>
</tr>
<tr>
</tr>
<tr>
<td><img src = "office1.jpg">
</td>
<td><img src = "office2.jpg">
</td>
<td><img src = "office3.jpg">
</td>
<td>
<font face="arial, helvetica" color="#000066" size="1"><b>The Table lists all <font color = #FF0000> <%=depat%> </font> Ts.</b></font>
</td>
</tr>
</table>
<table border = "1" width = "1060">
<tr>
<td><font face="arial, helvetica" color="#000066" size="1"><b>T</b></font></td>
<td><font face="arial, helvetica" color="#000066" size="1"><b>Size</b></font></td>
<td><font face="arial, helvetica" color="#000066" size="1"><b>Department</b></font></td>
</tr>
<%
'Loop through the recordset
Do While not rsGuestbook.EOF
if ((rsGuestBook("Department") = depat)) Then
'Write the HTML to display the current record in the recordset
t = rsGuestBook("T")
size = rsGuestBook("Size")
department = rsGuestBook("Department")
%>
<tr>
<td>
<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=t%></font>
</td>
</td>
<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=size%></font>
</td>
<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=department%></font>
</td>
</tr>
<% end if %>
<%
'Move to the next record in the recordset
rsGuestbook.MoveNext
Loop
'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>
</table>
<br>
<br>
<br>
<table>
<a href = "tmenu.asp"><font face="arial, helvetica" color="#000066" size="1">
Return to Main Menu</font></a>
</table>
<script>footer()</script>
<!-- end footer -->
</body>
</html>
Thank you very much.
Pal
I know this topic has been discussed quite a bit on this forum. I went through the examples but am still having some problems.
My output asp page has three images and an html table. I added the line at the top of the page to display the Excel page. I see the images overlapping the first row of the table (the column heading) but I don't see the actual records that are queried. It feels like the information is being displayed in the Excel Format before the recordset is entered.
Here's the code:
<%@ Language=VBScript %>
<%
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
%><html>
<head>
<title>View Ts</title>
</head>
<body bgcolor="white" text="black">
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim t
Dim size
Dim depat
Dim department
depat = Request.Form("department")
Response.write(depat)
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("t.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"
'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT TDetails.* FROM TDetails;"
'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon
%>
<br>
<br>
<br>
<br>
<br>
<table>
<tr>
<font face="arial, helvetica" color="#000066" size="2"><b>View Ts</b></font>
</tr>
<tr>
</tr>
<tr>
<td><img src = "office1.jpg">
</td>
<td><img src = "office2.jpg">
</td>
<td><img src = "office3.jpg">
</td>
<td>
<font face="arial, helvetica" color="#000066" size="1"><b>The Table lists all <font color = #FF0000> <%=depat%> </font> Ts.</b></font>
</td>
</tr>
</table>
<table border = "1" width = "1060">
<tr>
<td><font face="arial, helvetica" color="#000066" size="1"><b>T</b></font></td>
<td><font face="arial, helvetica" color="#000066" size="1"><b>Size</b></font></td>
<td><font face="arial, helvetica" color="#000066" size="1"><b>Department</b></font></td>
</tr>
<%
'Loop through the recordset
Do While not rsGuestbook.EOF
if ((rsGuestBook("Department") = depat)) Then
'Write the HTML to display the current record in the recordset
t = rsGuestBook("T")
size = rsGuestBook("Size")
department = rsGuestBook("Department")
%>
<tr>
<td>
<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=t%></font>
</td>
</td>
<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=size%></font>
</td>
<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=department%></font>
</td>
</tr>
<% end if %>
<%
'Move to the next record in the recordset
rsGuestbook.MoveNext
Loop
'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>
</table>
<br>
<br>
<br>
<table>
<a href = "tmenu.asp"><font face="arial, helvetica" color="#000066" size="1">
Return to Main Menu</font></a>
</table>
<script>footer()</script>
<!-- end footer -->
</body>
</html>
Thank you very much.
Pal