View Full Version : need help in writing a script to search students grades
theguy 06-20-2005, 08:22 AM 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
cerebis 06-20-2005, 08:45 AM 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 &";"
theguy 06-22-2005, 03:16 AM thanks
but that did not solve the problem
xelav 06-22-2005, 01:29 PM sql = "SELECT * FROM table_name WHERE stu_id=" & stu_id &";"
theguy 06-23-2005, 08:00 AM it did not solve the problem
anyone has a sugestion for me?
error404 06-23-2005, 08:31 AM 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.
cerebis 06-23-2005, 11:22 AM 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.
theguy 06-23-2005, 12:55 PM could you please post a link to a good tutorial you use
thanks
theguy 06-24-2005, 05:05 PM please help me
i just need a link to a good tutorial
theguy 06-26-2005, 01:38 AM someone please help me
RobertMaltby 06-26-2005, 02:15 AM I think its: www.sqlfreaks.com
If not google "SQL Freaks".. Lots of info on that site for you..
theguy 06-26-2005, 05:17 AM thanks but i'm getting site not found
and when searching google i do not get any related links
RobertMaltby 06-26-2005, 12:57 PM http://mysqlfreaks.com/ << there you go.. I thought it was sqlfreaks but its mysqlfreaks
theguy 06-27-2005, 01:40 AM thanks for the link
actually i'm looking for a tutorial about asp and access database not mysql
carguy84 06-27-2005, 02:14 AM 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-
error404 06-27-2005, 03:54 AM If that actually generates a fatal error, VB is even more crappy than I previously thought...
HosttonBiz 06-27-2005, 07:12 AM it may be a problem from the editor
carguy84 06-27-2005, 10:54 AM well, VB translates "" to " in a SQL query, so his statement would look like this to the DB:
SELECT * FROM marks WHERE id=10"
|