最初我的問題是我的帖子是重複的。我相信這是因爲我沒有在SQL語句中鏈接我的表。現在我已經完成了,我在我的if info.eof語句之後打印了「找不到數據」。爲什麼ASP沒有在我的數據庫中找到任何東西?
我確定數據庫中有信息,因爲我手動檢查過,但沒有成功。
這裏是我的代碼:
<% option explicit %>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="normalize.css">
</head>
<body>
<!--#include file="header.asp"-->
<!--#include file="dbconn.asp"-->
<%
dim sql, info
' 0 1 2 3 4 5
SQL = "select projectName, UserName, Category, Created, url, Projectstable.description "&_
"from ProjectsTable, PictureTable, Usertable, CategoryTable "&_
"where Projectstable.ID=PictureTable.projectNum AND "&_
"categoryNum=CategoryTable.ID AND "&_
"ProjectsTable.userNum=Usertable.ID AND "&_
"UserTable.ID=PictureTable.userNum "&_
"order by Created"
set info=conn.execute(SQL)
if info.eof then
response.write "<p>No Data Found</p>"
else
do
response.write "<h1>" & info(0) & "</h1> By: " & info(1) & " Posted in: " & info(2) & " Created on: " & info(3) & "<br>" &_
"<img src=""images/" &info(4)&""">" &_
"<p>" & info(5) & "</p>"
info.movenext
loop until info.eof
end if
conn.close
%>
</body>
</html>
您是否試圖提取查詢並直接對數據庫運行它(如果您使用的是SQL Server,則在管理工作室中運行)。它顯示結果嗎? – mortb
@mortb你不得不原諒我,因爲我不明白你的建議。我的數據庫在Microsoft Access上。 – chap
問題可能出在dbconn.asp – John