Advertisement

06.15.2008 at 08:29PM PDT, ID: 23487031
[x]
Attachment Details

Having trouble returning query results to an HTML page.

Asked by juliancaldwellomaha in MySQL, .NET

Tags: ASP VP .NET MySQL, Mozilla Firefox and Internet Exporer, {"Operator '&' is not defined for string "" and type 'Field'."}

I am attempting to simply connect to a MySQL database, query it, return the data, and display it on a webpage.   Simple enough.  

Well, not so lucky so far.  I am getting "{"Operator '&' is not defined for string "<tr><td>" and type 'Field'."}" as an error message with my code, which is attached below.  

I am new to .NET, so I am sure this is probably a very simple problem, but so far, I have been unable to figure it out. Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
<%@ Page aspcompat=true  Language="VB" AutoEventWireup="false" CodeFile="read_db.aspx.vb" Inherits="read_db" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    
Results of a Simple Database Query
 
 
<% Dim Connect, Addresses, Query %>
 
<% 'Now, create a server object which will be a DNS connection %>
 
<%  Connect = Server.CreateObject("ADODB.Connection")%>
 
<% 'Open the connection to the right DSN %>
 
<%  Connect.Open("bellevue_db")%>
 
<% 'Form a SQL query (in this case, get everything from the mytable table) %>
 
<%  Addresses = Connect.Execute("SELECT * From MyTable") %>
    If Addresses.EOF Then _
        <%Response.Write("<tr><td>No results to display.</td></tr>")%>
Do While Not Addresses.EOF
        <%Response.Write("<tr><td>" & Addresses.Fields("Name") & "</td>")%>
        <%Response.Write("<td>" & Addresses.Fields("age_Range") & "</td>")%>
        <%Response.Write("<td>" & Addresses.Fields("salary_range") & "</td></tr>")%>
    Addresses.MoveNext
Loop
%>
</table></body>
 
 
</body>
</html>
[+][-]06.16.2008 at 01:46AM PDT, ID: 21791740

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MySQL, .NET
Tags: ASP VP .NET MySQL, Mozilla Firefox and Internet Exporer, {"Operator '&' is not defined for string "<tr><td>" and type 'Field'."}
Sign Up Now!
Solution Provided By: TomasHelgi
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628