LandMonster
Programmer
Hi, Here's my problem. I am trying to insert a record into a access 2000 database from an asp page. I have asked a few friends, and everybody agrees that my code looks good. But for some reason it will not insert a record into the database.
Here is the code:
<%@ Language = "VBScript" %>
<%
Option Explicit
Dim cnnPost
Dim strMessage
Dim strSQL
%>
<html>
<head><title>Post you filthy bastard</title>
</head>
<body bgcolor="black">
<form action="main.asp" method="post">
<input type="hidden" name="action" value="post_message" />
<table border="0" align="center">
<tr>
<td><textarea cols="75" rows="8" name="message"></textarea></td>
<td><input type="submit" VALUE="Post" /></td>
</tr>
</table>
</form>
<%
'strSQL = "INSERT INTO Messages (User, Date, Message) " _
' & "VALUES(kuba, 5/9/2003, '" & Replace(Request.Form("message") & "');"
'strSQL = "INSERT INTO Messages (User, Date, Message) " _
' & "VALUES('kuba', '"&cstr(date())&"','" & Replace(Request.Form("message") & "');"
strSQL = "INSERT INTO Messages (User, Date, Message) VALUES('kuba', '5/9/2003', '" & Replace(Request.Form("message") & "');"
Set cnnPost = Server.CreateObject("ADODB.Connection"
cnnPost.Open("DRIVER={Microsoft Access Driver (*.mdb)};" _
& "DBQ=" & Server.MapPath("db\Monster.mdb")
cnnPost.Execute(strSQL)
' Clean Up
cnnPost.Close
Set cnnPost = Nothing
%>
<br>
</body>
<html>
Can anybody tell me what I'm doing wrong?
Thanks
Here is the code:
<%@ Language = "VBScript" %>
<%
Option Explicit
Dim cnnPost
Dim strMessage
Dim strSQL
%>
<html>
<head><title>Post you filthy bastard</title>
</head>
<body bgcolor="black">
<form action="main.asp" method="post">
<input type="hidden" name="action" value="post_message" />
<table border="0" align="center">
<tr>
<td><textarea cols="75" rows="8" name="message"></textarea></td>
<td><input type="submit" VALUE="Post" /></td>
</tr>
</table>
</form>
<%
'strSQL = "INSERT INTO Messages (User, Date, Message) " _
' & "VALUES(kuba, 5/9/2003, '" & Replace(Request.Form("message") & "');"
'strSQL = "INSERT INTO Messages (User, Date, Message) " _
' & "VALUES('kuba', '"&cstr(date())&"','" & Replace(Request.Form("message") & "');"
strSQL = "INSERT INTO Messages (User, Date, Message) VALUES('kuba', '5/9/2003', '" & Replace(Request.Form("message") & "');"
Set cnnPost = Server.CreateObject("ADODB.Connection"
cnnPost.Open("DRIVER={Microsoft Access Driver (*.mdb)};" _
& "DBQ=" & Server.MapPath("db\Monster.mdb")
cnnPost.Execute(strSQL)
' Clean Up
cnnPost.Close
Set cnnPost = Nothing
%>
<br>
</body>
<html>
Can anybody tell me what I'm doing wrong?
Thanks