Click to See Complete Forum and Search --> : why doesn't it insert in database?


gilgalbiblewhee
06-15-2006, 05:32 PM
<html>

<body>

<form action="feedbacksent.asp" method="get" enctype="text/plain">

<h3>Your feedback is important.</h3>
<h5>To send your comments put your:</h5><br>
Name:<br>
<input type="text" name="name" size="18" value="Put your name" class="form-input" onBlur="if(this.value==''){this.value='Put your name';}" onFocus="if(this.value=='Put your name'){this.value='';}">

<br>
Email:<br>
<input type="text" name="email" size="22" value="Put your email address" class="form-input" onBlur="if(this.value==''){this.value='Put your email address';}" onFocus="if(this.value=='Put your email address'){this.value='';}">

<br>
Subject:<br>
<input type="text" name="subject" size="40" value="Put your subject" class="form-input" onBlur="if(this.value==''){this.value='Put your subject';}" onFocus="if(this.value=='Put your subject'){this.value='';}">

<br>
<textarea rows="10" name="comment" cols="60" value="Put your comments" class="form-input" onBlur="if(this.value==''){this.value='Put your comments';}" onFocus="if(this.value=='Put your comments'){this.value='';}"></textarea>
<br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">

</form>
</body>
</html>

<html>
<body>

<%
'Dim connStr
'connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("Kjv.mdb")
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "kjv.mdb"

sql="INSERT INTO feedback (ID,name,"
sql=sql & "subject,email,comment)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("ID") & "',"
sql=sql & "'" & Request.Form("name") & "',"
sql=sql & "'" & Request.Form("email") & "',"
sql=sql & "'" & Request.Form("subject") & "',"
sql=sql & "'" & Request.Form("comment") & "')"

on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>

</body>
</html>

chrismartz
06-15-2006, 06:24 PM
What do you have set for recaffected in conn.Execute sql,recaffected?

gilgalbiblewhee
06-15-2006, 06:40 PM
Nothing. This was from:
http://www.w3schools.com/ado/ado_add.asp
Do I have to add a hidden field for the ID? If so how will it be a new ID all the time so that it won't update on the same record?

russell
06-16-2006, 02:02 AM
gilga, take out the On Error Resume Next so you can see what the error is. Also, on the line above it do a Response.Write sql so you can see what is being passed to the database.

also, in IE go to tools / internet options / advanced
and make sure "Show Friendly HTTP Error Messages" is NOT checked -- if u haven't already...this will help u debug

post back if the response.write sql doesnt point out your problem 4 u.

russell
06-16-2006, 02:06 AM
also, i'm not sure that msaccess will pass back the recs affected that way. i bet thats the error right there. take it out, see if that does the trick. but dont forget to remove the on error resume next so u can see exactly where its failing

EDIT :: WHooooaaa, i just looked at that W3Schools link. They are flat out wrong on their example. I usually like that site...