Results 1 to 18 of 18
  1. #1
    Join Date
    Jan 2002
    Posts
    83

    need help in writing a script to search students grades

    i have an access database which has one table called marks and the table contains 5 fields
    ID : auto number
    stu_id: number
    course_number: number
    course_title: text
    grades: number

    now i want the student to enter his student id number and be able to see his grades for all courses taken during the semester.

    so this ASP script does not seem to work, what am i doing wrong?
    what changes needed?

    Dim stu_id
    stu_id=request.form("student_id")

    Dim oConn, sConnString,sql
    Set oConn = Server.CreateObject("ADODB.Connection")
    sConnString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("dbname.mdb") & ";"
    oConn.Open(sConnString)
    sql = "SELECT * FROM table_name WHERE id=" & stu_id &""

    Dim results
    set results=oConn.Execute(sql)

    '
    'statements for processing or displaying results
    '
    oConn.Close

  2. #2
    Join Date
    May 2005
    Location
    Sydney Australia
    Posts
    81
    Am I wrong in thinking you need to terminate sql queries in Access with a semi-colon?

    IE.

    sql = "SELECT * FROM table_name WHERE id=" & stu_id &";"
    Last edited by cerebis; 06-20-2005 at 08:48 AM.

  3. #3
    Join Date
    Jan 2002
    Posts
    83
    thanks
    but that did not solve the problem

  4. #4
    sql = "SELECT * FROM table_name WHERE stu_id=" & stu_id &";"
    HostNodeList Web Host Directory, DEV.INTOEX.COM - products for online business

    Experienced web-developer | PHP | Smarty | Zend | Databases | Graphic design - looking for long-time relationship

  5. #5
    Join Date
    Jan 2002
    Posts
    83
    it did not solve the problem

    anyone has a sugestion for me?

  6. #6
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    1,082
    Uh. Do you have any idea whatsoever what you're doing?

    table_name should be (surprise) your table name, which you've said is marks. You'll also want to use stu_id rather than id as xelav suggested.

    In the future, if you're going to report a problem, try and give a bit more information than 'it did not solve the problem'. Define exactly what 'its not working' means, and pass on any error messages or output that you get.

  7. #7
    Join Date
    May 2005
    Location
    Sydney Australia
    Posts
    81
    You'd be greatly benefited by reading just about any SQL tutorial on the Net. The syntax can vary slightly from implementation to implementation, but there are a lot of references out there.

    An example just like your question would be on about page 2 or 3.

  8. #8
    Join Date
    Jan 2002
    Posts
    83
    could you please post a link to a good tutorial you use

    thanks

  9. #9
    Join Date
    Jan 2002
    Posts
    83
    please help me

    i just need a link to a good tutorial

  10. #10
    Join Date
    Jan 2002
    Posts
    83
    someone please help me

  11. #11
    Join Date
    May 2004
    Location
    Milton, Florida
    Posts
    783
    I think its: www.sqlfreaks.com

    If not google "SQL Freaks".. Lots of info on that site for you..

  12. #12
    Join Date
    Jan 2002
    Posts
    83
    thanks but i'm getting site not found
    and when searching google i do not get any related links

  13. #13
    Join Date
    May 2004
    Location
    Milton, Florida
    Posts
    783
    http://mysqlfreaks.com/ << there you go.. I thought it was sqlfreaks but its mysqlfreaks

  14. #14
    Join Date
    Jan 2002
    Posts
    83
    thanks for the link

    actually i'm looking for a tutorial about asp and access database not mysql

  15. #15
    Dim stu_id
    stu_id = cInt(request.form("student_id"))

    if stu_id > 0 then
    sql = "SELECT * FROM marks WHERE id=" & stu_id
    end if

    Your basic error was having a " at the end of your SQL statement. you don't need anything after the statement if it ends in a variable like that.

    Chip-

  16. #16
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    1,082

  17. #17
    it may be a problem from the editor

  18. #18
    well, VB translates "" to " in a SQL query, so his statement would look like this to the DB:

    SELECT * FROM marks WHERE id=10"

Posting Permissions

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