html connection

I am getting this error when trying to connect to database called student.mbd



Students Details

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xa04 Thread 0x7ec DBC 0x98ae244 Jet'.

/powerger/db/Students.asp, line 12

this is the html code for it


<html>
<head>
<title>Ger Power</title>
</head>
<body>

<font face="Arial" size="4" color="#000080">
<p>Students Details</p>

<%
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db\student.mdb"))

'First we should check if trying to insert
'Only execute the INSERT statement if it has been requested
If Request("submit") = "Insert" Then
    sSQL = "INSERT INTO Student VALUES ('" & Request("student name") & "', '" & Request("student no") & "', '" & Request("student email") & "'," &   Request("exam marks") & ")"
    Response.Write("SQL Query: " & sSQL & "<BR><BR>")
    oConn.Execute(sSQL)
End If

'SELECT from the database
sSQL = "SELECT * FROM student"
set oRS = oConn.Execute(sSQL)

'Print headings
Response.Write("<table border=1 cellpadding=1 cellspacing=1 style='font-family:arial;font-size:10pt;'>")
Response.Write("<tr bgcolor=black style='color:blue;'><td>Student Name</td>")
Response.Write("<td>Student No</td>")
Response.Write("<td>Student Email address</td>")
Response.Write("<td>Exam Marks</td></tr>")

'Print rows from record set
Do While NOT oRS.EOF
    Response.Write("<tr><td>" & oRS("Student Name") & "</td>")
    Response.Write("<td>" & oRS("Student No") & "</td>")      
    Response.Write("<td>" & oRS("Student Email") & "</td>")
    Response.Write("<td align=right>" & oRS("Exam Marks") & "</td></tr>")
    oRS.MoveNext
Loop

'End of table
Response.Write("</table><br><br>")

oConn.Close
Set oRS = Nothing
Set oConn = Nothing
%>

<p>Add a Student</p>
<form method="GET" action="Students.asp">
  <p>Student Name:<input type="text" name="student name" size="20"></p>
  <p>Student No: <input type="text" name="student no" size="20"></p>
  <p>Student Email address: <input type="text" name="student email" size="20"></p>
  <p>Exam Marks: <input type="text" name="exam marks" size="20"></p>
  <p><input type="submit" value="Insert" name="submit"></p>
</form>
</font>

</body>
</html>








powergerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
DreamMasterConnect With a Mentor Commented:
Could you please tell us what your field names are in the database?

Also, please try not to execute the code...but do a response.write of sSQL

The resulting query should look right...if you are in any doubt, and even if you're not...copy that string and try executing it from your Access Database directly (using a query in SQL view)

If that works, you can be pretty sure your code for the SQL string is ok and we can move on to the rest of the code...

Oh...and please..post the sSQL string here for our reference...

Thanks,
Max.
0
 
powergerAuthor Commented:
Just to let you know i am trying to post this on a website called brinkster, with a students.asp connecting to a database called student.mbd
0
 
powergerAuthor Commented:
I fixed the first error, now i am getting this error

[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

/powerger/Students.asp, line 19
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
danataylorCommented:
Don't you need to tell the DB what fields the data goes into?

sSQL = "INSERT INTO Student VALUES ('" & Request("student name") & "', '" & Request("student no") & "', '" & Request("student email") & "'," & request("exam marks") & ")"

Becomes

sSQL = "INSERT INTO Student (name, ID, email, score) VALUES ('" & Request("student name") & "', '" & Request("student no") & "', '" & Request("student email") & "'," & request("exam marks") & ")"
0
 
powergerAuthor Commented:
I have changed around the code and done what you said but i am getting this error now

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

/powerger/Students.asp, line 19


<html>
<head>
<title>Ger Power</title>
</head>
<body>

<font face="Arial" size="4" color="#000080">
<p>Students Details</p>

<%
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db\student.mdb"))

'First we should check if trying to insert
'Only execute the INSERT statement if it has been requested
If Request("submit") = "Insert" Then
    sSQL = "INSERT INTO student (Student Name,Student Id,Student Email,Exam Marks) VALUES ('" & Request("student name") & "', " & Request("student id") & ",'" & Request("student email") & "'," &   Request("exam marks") & ")"
    Response.Write("SQL Query: " & sSQL & "<BR><BR>")
    oConn.Execute(sSQL)
End If

'SELECT from the database
sSQL = "SELECT * FROM student"
set oRS = oConn.Execute(sSQL)

'Print headings
Response.Write("<table border=1 cellpadding=1 cellspacing=1 style='font-family:arial;font-size:10pt;'>")
Response.Write("<tr bgcolor=black style='color:black;'><td>Student Name</td>")
Response.Write("<td>Student Id</td>")
Response.Write("<td>Student Email address</td>")
Response.Write("<td>Exam Marks</td></tr>")

'Print rows from record set
Do While NOT oRS.EOF
    Response.Write("<tr><td>" & oRS("Student Name") & "</td>")
    Response.Write("<td>" & oRS("Student Id") & "</td>")      
    Response.Write("<td>" & oRS("Student Email") & "</td>")
    Response.Write("<td align=right>" & oRS("Exam Marks") & "</td></tr>")
    oRS.MoveNext
Loop

'End of table
Response.Write("</table><br><br>")

oConn.Close
Set oRS = Nothing
Set oConn = Nothing
%>

<p>Add a Student</p>
<form method="GET" action="Students.asp">
  <p>Student Name:<input type="text" name="student name" size="30"></p>
  <p>Student No: <input type="text" name="student id" size="30"></p>
  <p>Student Email address: <input type="text" name="student email" size="50"></p>
  <p>Exam Marks: <input type="text" name="exam marks" size="20"></p>
  <p><input type="submit" value="Insert" name="submit"></p>
</form>
</font>

</body>
</html>









0
 
danataylorCommented:
First: Are these the real names of the data fields in your table?
   (Student Name,Student Id,Student Email,Exam Marks)

Second: Using whitespace characters in a field/column name is not recommended.  It makes it hard to refer to them as variables.  Try double-quoting the column names.  I'm not 100% sure it will work but it's worth a try.
    ("Student Name","Student Id","Student Email","Exam Marks")
0
 
powergerAuthor Commented:
I took out the spaces in the database, and renamed the code, getting no syntax errors, back to this error

[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

/powerger/Students.asp, line 19
0
 
danataylorConnect With a Mentor Commented:
Check the rights on the db\student.mdb file and make everyone has R/W priviledges.
0
All Courses

From novice to tech pro — start learning today.