I am completely new to using a MySQLDB but I'm surprised that this doesn't work. Basically, I'm selecting all records from my NEWS database table.
There are definately two rows of test data in the NEWS table so they should be fetched row by row, but without the loop on, nothing is returned. With the loop on, nothing is returned again, but it takes longer. This suggests to me that there is a looping issue but I have used this same syntax on many loops in VBScript and without the loop, nothing is returned.
Any ideas?
The Code:
<PRE>
<HTML>
<head>
<title></title>
</head>
<%
ON ERROR RESUME NEXT
DebugMode = "True"
TodaysDate=Date()
TodaysDate_D=Day(TodaysDate)
TodaysDate_M=Month(TodaysDate)
TodaysDate_Y=Year(TodaysDate)
SQL=" SELECT TITLE, PUB_DATE, PARA1, PARA2, PARA3, PARA4, PARA5, PARA6, PARA7, PARA8 "
SQL=SQL &" FROM NEWS "
SQL=SQL &" WHERE PUB_DATE >= '" & TodaysDate & "' "
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.ActiveConnection = "Driver={MySQL}; DATABASE=Blah; UID=Blah; PASSWORD=Blah; Server=Blah;"
rs.Open SQL, strConnect,3,3
%>
<body>
<table>
<tr>
<td>TITLE</td>
<td>PUBLICATION DATE</td>
<td>PARAGRAPH 1</td>
<td>PARAGRAPH 2</td>
<td>PARAGRAPH 3</td>
<td>PARAGRAPH 4</td>
<td>PARAGRAPH 5</td>
<td>PARAGRAPH 6</td>
<td>PARAGRAPH 7</td>
<td>PARAGRAPH 8</td>
</tr>
<% If Not rs.eof Then
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
%>
<tr>
<td> <%=Server.HTMLEncode(rs.Fields("TITLE").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PUB_DATE").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA1").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA2").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA3").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA4").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA5").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA6").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA7").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA8").Value)%></td>
</tr>
<% rs.MoveNext
loop
Else %>
<tr>
<td colspan="4">No Cases found matching the criteria!</td>
</tr>
<% End If %>
</table>
<%
If DebugMode = "True" Then
%>
SQL Code = <%=SQL%><BR>
<%=TodaysDate%>
<%
End If
%>
</body>
</html>
</PRE>
There are definately two rows of test data in the NEWS table so they should be fetched row by row, but without the loop on, nothing is returned. With the loop on, nothing is returned again, but it takes longer. This suggests to me that there is a looping issue but I have used this same syntax on many loops in VBScript and without the loop, nothing is returned.
Any ideas?
The Code:
<PRE>
<HTML>
<head>
<title></title>
</head>
<%
ON ERROR RESUME NEXT
DebugMode = "True"
TodaysDate=Date()
TodaysDate_D=Day(TodaysDate)
TodaysDate_M=Month(TodaysDate)
TodaysDate_Y=Year(TodaysDate)
SQL=" SELECT TITLE, PUB_DATE, PARA1, PARA2, PARA3, PARA4, PARA5, PARA6, PARA7, PARA8 "
SQL=SQL &" FROM NEWS "
SQL=SQL &" WHERE PUB_DATE >= '" & TodaysDate & "' "
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.ActiveConnection = "Driver={MySQL}; DATABASE=Blah; UID=Blah; PASSWORD=Blah; Server=Blah;"
rs.Open SQL, strConnect,3,3
%>
<body>
<table>
<tr>
<td>TITLE</td>
<td>PUBLICATION DATE</td>
<td>PARAGRAPH 1</td>
<td>PARAGRAPH 2</td>
<td>PARAGRAPH 3</td>
<td>PARAGRAPH 4</td>
<td>PARAGRAPH 5</td>
<td>PARAGRAPH 6</td>
<td>PARAGRAPH 7</td>
<td>PARAGRAPH 8</td>
</tr>
<% If Not rs.eof Then
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
%>
<tr>
<td> <%=Server.HTMLEncode(rs.Fields("TITLE").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PUB_DATE").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA1").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA2").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA3").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA4").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA5").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA6").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA7").Value)%></td>
<td> <%=Server.HTMLEncode(rs.Fields("PARA8").Value)%></td>
</tr>
<% rs.MoveNext
loop
Else %>
<tr>
<td colspan="4">No Cases found matching the criteria!</td>
</tr>
<% End If %>
</table>
<%
If DebugMode = "True" Then
%>
SQL Code = <%=SQL%><BR>
<%=TodaysDate%>
<%
End If
%>
</body>
</html>
</PRE>