Forum Moderators: open

Message Too Old, No Replies

help me correct the problems with this script

         

thenewguy2

8:41 pm on Feb 8, 2006 (gmt 0)



when i run this script i get internal server error
please take a look at it and tell me where i made a mistake to correct it

<%
Option Explicit

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("/_private/marks.mdb") & ";"
oConn.Open(sConnString)
sql = "SELECT * FROM marks WHERE id=" & stu_id &""

Dim results
set results=oConn.Execute(sql)

Response.Write "<table>"
Response.Write "<tr>"
Response.Write "<td>ID</td>"
Response.Write "<td>stu_id</td>"
Response.Write "<td>Course Number</td>"
Response.Write "<td>Course Title</td>"
Response.Write "<td>Grades</td>"
Response.Write "</tr>"

set results=oConn.Execute(sql)
If not Results.EOF then
Response.Write "<tr>"
Response.Write "<td>" & Results("ID") & "</td>"
Response.Write "<td>" & Results("stu_id") & "</td>"
Response.Write "<td>" & Results("course_number") & "</td>"
Response.Write "<td>" & Results("course_title") & "</td>"
Response.Write "<td>" & Results("grades") & "</td>"
Response.Write "</tr>"

'Use the loop if you will be retreiving multiple records.
'Do WHile Not Results.EOF
' Response.Write "<tr>"
' Response.Write "<td>" & Results("ID") & "</td>"
' Response.Write "<td>" & Results("stu_id") & "</td>"
' Response.Write "<td>" & Results("course_number") & "</td>"
' Response.Write "<td>" & Results("course_title") & "</td>"
' Response.Write "<td>" & Results("grades") & "</td>"
' Response.Write "</tr>"
' Results.MoveNext
'Loop
Else
Response.Write "<tr>"
Response.Write "<td colspan=5>No records found..</td>"
Response.Write "</tr>"
End If
Response.Write "</table>
%>

miedmark

10:13 pm on Feb 8, 2006 (gmt 0)

10+ Year Member



Would you mind telling what error are you getting? Turn off your friendly error and post

macrost

10:14 pm on Feb 8, 2006 (gmt 0)

10+ Year Member



When you have the 500 internal error, that means you have show friendly HTTP error messages on. To turn it off, go to
tools -> internet options -> advanced. Scroll down and uncheck the box marked "Show friendly HTTP error messages."

Once that's done, rerun your script and you will receive the error on what's happening.
<added>LOL, looks like miedmark and I posted at the same time!</added>

<added again>After looking at the code, find this line:
sql = "SELECT * FROM marks WHERE id=" & stu_id &""

I notice that you have an extra double quote at the end. Actually, with stu_id, you shouldn't need the last part: &"".
</added again>

celgins

12:58 am on Feb 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm also assuming...(by looking at your code)...that your "marks.mdb" database contains a table named, "marks"?

Like the other posts, change your error message settings in your browser, re-run your script, and it should show you a better constructed error message.

miedmark

12:58 am on Feb 10, 2006 (gmt 0)

10+ Year Member



macrost - looks like we both posted at the same time.

You know what a cool feature would be on ww (or any other forum) - while you're posting a reply it should check if the thread has changed since you started typing - like this:
This thread has changed since you clicked reply (would you like to view?). It would give you an option to modify your post before posting.

Just an idea.