clarkey boy
New Member
Hi,
I have only been learning ASP for several days now and am hoping to become a professional web designer.
I used the following code for my page - it does not come up with any errors and I used basically the same code for another page (which does work), but this page does not work as it will not submit comments from the form into the database. I would be very grateful for any help anyone could give me.
Displaying the information from the database works fine - so the connection is definitely there - but I can't get it to create new records.
I have a database called comments, a table called comments and the column being taken from the table is also called comments - not necessarily a very good combination to call them all comments but its easy to handle at this stage.
I have only been learning ASP for several days now and am hoping to become a professional web designer.
I used the following code for my page - it does not come up with any errors and I used basically the same code for another page (which does work), but this page does not work as it will not submit comments from the form into the database. I would be very grateful for any help anyone could give me.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Comments</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
Dim adoCon
Dim rscomments
Dim SQL
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Mode=admodesharedenynone
adoCon.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=d:\websites/clarkeyboy/datasource/comments.mdb")
Set rscomments = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT comments FROM comments"
rscomments.CursorType = 2
rscomments.LockType = 3
rscomments.Open SQL, adoCon
%>
<form>
<strong>
Comments: (Place your comments here and press enter)
</strong>
<input type="text" rows="20" cols="150" name="comment">
</form>
<table align="center" border="3" width="100%">
<tr>
<td width="10%">
<b>
<center>
Comment Number
</center>
</b>
</td>
<td width="90%">
<b>
<center>
Comments
</center>
</b>
</td>
</tr>
<%
Dim x
x = 0
Do While not rscomments.EOF
%>
<tr>
<td width="50%">
<%
x = x + 1
Response.Write(x)
%>
</td>
<td width="50%">
<%
Response.Write (rscomments("comments"))
%>
</td>
</tr>
<%
rscomments.MoveNext
Loop
%>
</table>
<%
Dim strcomment
strcomment = Request.Form("comment")
Dim strNothing
strNothing = ""
If strcomment = strNothing Then
Response.Write("Please submit a comment")
Else
rscomments.addnew
rscomments("comments") = strComment
rscomments.update
Response.Redirect"comments.asp"
Response.Write("Thank you for submitting a comment")
End If
rscomments.Close
%>
</body>
</html>
Displaying the information from the database works fine - so the connection is definitely there - but I can't get it to create new records.
I have a database called comments, a table called comments and the column being taken from the table is also called comments - not necessarily a very good combination to call them all comments but its easy to handle at this stage.