Results 1 to 3 of 3

Thread: help?

  1. #1
    Join Date
    May 2004
    Posts
    6

    Unanswered: help?

    Hello there !!

    I have Create this page which will receive the staffID from form page. Based on that information it should extract the unitIDs, names and semesters of all units coordinated by this staff member and display in a table


    But When i run it i get this

    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'coordination.staffID = and unit.unitID = coordination.unitID and coordination.staffID = staff.staffID'

    If anyone could help me with this?

    Thanx for your time.


    <%@ Language="VBScript" %>
    <?xml version="1.0" encoding="utf-8"?>
    <!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">
    <% set myConnection=server.createobject("ADODB.connection ")
    myConnection.open "Outline", "IWSDStudent", "assign2"
    sID = request.form("staffID") 'retrieve the StaffID
    'use the Staff ID to retrieve the info from the db
    mySQL = "select coordination.unitID, unit.unitname, "
    mySQL = mySQL & "coordination.semester from unit, staff, coordination"
    mySQL = mySQL & " where coordination.staffID = " & sID & " and "
    mySQL = mySQL & "unit.unitID=coordination.unitID and "
    mySQL = mySQL & "coordination.staffID =staff.staffID"
    set myRS = myConnection.execute(mySQL)
    %>
    <body>
    <h2>Units coordinated by: <%=sID%></h2>
    <table border="1" summary="Coordination details">
    <tr><td>Unit ID</td><td>Unit Name</td><td>Semester</td></tr>
    <%
    do while not myRS.eof
    %>
    <tr><td><%= myRS ("unitID")%></td>
    <td><%= myRS ("unitname")%></td>
    <td><%= myRS ("semester")%></td>
    </tr>
    <%
    myRS.movenext
    loop
    %>
    </table>
    <br /><p><a href="ex8.htm">Return to the form</a></p>
    </body>
    </html>

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'coordination.staffID = and unit.unitID = coordination.unitID and coordination.staffID = staff.staffID'
    The answer is in the error...

    ...coordination.staffID = and...

    There is no value between the "=" and the "and"... so look back in your code where this line is:

    mySQL = mySQL & " where coordination.staffID = " & sID & " and "

    So the value that should be between the "=" and the "and" is from sID. For some reason sID is blank. So look for where you set the value of sID:

    sID = request.form("staffID") 'retrieve the StaffID

    Ok, so you're getting it from a form... now you need to look back on the form that you submit and make sure "staffID" is in fact passing a value.
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    May 2004
    Posts
    6
    Thanx !

    I have solve that with your help, again thanx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •