Click to See Complete Forum and Search --> : ASP Database help!


danz321
03-07-2006, 08:57 AM
Hi, when i run the page below, i get an error sayin there is an error in the FROM clause on line 14. really cant work it out. im quite new to asp so forgive me if its a piece of piss! pleaes help!!

<%

set db=Server.CreateObject("ADODB.Connection")
db.Provider="Microsoft.Jet.OLEDB.4.0"
db.Open "c:/peaksite/dev2/peak.mdb"

set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Group", db
rs.Open "Link", db
%>
<html>
<body>
<%
Dim Groups, Links
Groups = db.Execute("SELECT id, name FROM Group ORDER BY id")
While Not Groups.EOF
%>
<div id="group_<%=Groups(0)%>"><%=Groups(1)%></div>
<%
Links = db.Execute("SELECT id, name, url, description FROM Link WHERE GroupId = " + Groups(0) + " ORDER BY id")
While Not Links.EOF
%>
<div id="link_<%=Links(0)%>">
<a href="<%=Links(2)%>" title="<%=Links(3)%>">
<%=Links(1)%>
</a>
</div>
<%
Links.MoveNext
Wend
Groups.MoveNext
Wend
%>
</body>
</html>

zingmatter
03-07-2006, 10:55 AM
Firstly check spelling. Also, beware of names that might be reserved words in SQL (e.g. don't have a table field called 'Date').

The easiest thing to do is to copy and paste the SQL statement into Access and try to run it directly. It will probably give you a clearer explanation of what the error is.

chrismartz
03-07-2006, 11:10 AM
Try " & Groups(0) & " instead of what you have in your select statement.

danz321
03-07-2006, 11:42 AM
all spelling seems to be accurate, and changing the groups(0) bit didnt help :s .... how would i run the SQL line in access? im a complete noob to this! :|

zingmatter
03-07-2006, 01:52 PM
Go to Queries and double click Create Query in Design View. Close the box and click the top left tab saying SQL.

danz321
03-08-2006, 08:23 AM
right, so i did that, and i get the same error in access..."syntax error in from clause" and it highlighted the word "Group" in the line

Groups = db.Execute("SELECT id, name FROM Group ORDER BY id")

i looked it up in the help and it said

Possible causes:

- A reserved word or argument name is misspelled or missing.
- Punctuation is incorrect.

so i changed the name to "groups" (even though the table name is definatly "group")
and it said that it could not find the table or query "groups"

this lead me to the conclusion that it can find the table in the first place, so im not sure what is causing the error? any ideas?

russell_g_1
03-08-2006, 05:08 PM
group is a keyword in sql, i.e. it actually means something. try putting [ and ] around the table name.

danz321
03-10-2006, 07:12 AM
ok so i tried puting [ and ] around the table name and it didnt work. so i changed the name altogether to something else. ie. table name and all the code relating to the table name. and i got an error saying:

Object doesn't support this property or method: 'EOF' - on line 15

Line 15: While Not Clans.EOF

im completlly lost now
help!

Terrorke
03-10-2006, 07:20 AM
Make sure that 'clans' is a recordset