Click to See Complete Forum and Search --> : any problems with this code???


dhayes
04-05-2005, 07:57 AM
hey guys im trying to display informtion and images from my database with this code but the server does not seem to display anything i am very new to asp and any help would be appreciated thanks. Heres the code

<%
Dim adoCon
Dim rs
Dim strSQL
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("clothes.mdb")
Set rs= Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT products.Brand, products.Category, products.Sex, products.Price, products.Description, products.Image FROM products WHERE Brand='Matix'"


strSQL = "SELECT products.Brand, products.Category, products.Sex, products.Price, products.Description, products.Image FROM products WHERE Brand='Matix'"



rs.Open strSQL, adoCon

Do While not rs.EOF
%>

<table border="0">
<tr>
<td>Brand:</td>
<td><% Respone.Write rs("Brand") %></td>
</tr>
<tr>
<td>Category:</td>
<td><% Respone.Write rs("Category") %></td>
</tr>
<tr>
<td>Sex:</td>
<td><% Respone.Write rs("Sex") %></td>
</tr>
<tr>
<td>Price:</td>
<td><% Respone.Write rs("Price") %></td>
</tr>
<tr>
<td>Description:</td>
<td><% Respone.Write rs("Description") %></td>
</tr>
<tr>
<td>Image:</td>
<td><img src="<% Respone.Write rs("Image") %>" border="0"></td>
</tr>
</table>

<%
Loop
rs.Close
Set rs = Nothing
Set adoCon = Nothing
%>

phpnovice
04-05-2005, 12:31 PM
First, as a suggestion (not, necessarily, a fix), for the following type of coding:

<% Respone.Write rs("Brand") %>

I would explicitly code recordset field references as follows:

<% Respone.Write rs.Fields("Brand").Value %>

and you can also use the following short-cut for Response.Write:

<%= rs.Fields("Brand").Value %>

Then, as one fix, change this part:

</table>

<%
Loop

to this:

</table>

<%
rs.MoveNext
Loop