Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting record into MS access 2000 database from asp page not workin

Status
Not open for further replies.

LandMonster

Programmer
Feb 4, 2002
11
CA
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 = &quot;VBScript&quot; %>

<%
Option Explicit

Dim cnnPost
Dim strMessage
Dim strSQL

%>
<html>
<head><title>Post you filthy bastard</title>
</head>
<body bgcolor=&quot;black&quot;>

<form action=&quot;main.asp&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;post_message&quot; />
<table border=&quot;0&quot; align=&quot;center&quot;>
<tr>
<td><textarea cols=&quot;75&quot; rows=&quot;8&quot; name=&quot;message&quot;></textarea></td>
<td><input type=&quot;submit&quot; VALUE=&quot;Post&quot; /></td>
</tr>
</table>
</form>

<%
'strSQL = &quot;INSERT INTO Messages (User, Date, Message) &quot; _
' & &quot;VALUES(kuba, 5/9/2003, '&quot; & Replace(Request.Form(&quot;message&quot;)) & &quot;');&quot;
'strSQL = &quot;INSERT INTO Messages (User, Date, Message) &quot; _
' & &quot;VALUES('kuba', '&quot;&cstr(date())&&quot;','&quot; & Replace(Request.Form(&quot;message&quot;)) & &quot;');&quot;
strSQL = &quot;INSERT INTO Messages (User, Date, Message) VALUES('kuba', '5/9/2003', '&quot; & Replace(Request.Form(&quot;message&quot;)) & &quot;');&quot;

Set cnnPost = Server.CreateObject(&quot;ADODB.Connection&quot;)
cnnPost.Open(&quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot; _
& &quot;DBQ=&quot; & Server.MapPath(&quot;db\Monster.mdb&quot;))

cnnPost.Execute(strSQL)

' Clean Up
cnnPost.Close
Set cnnPost = Nothing
%>
<br>
</body>
<html>

Can anybody tell me what I'm doing wrong?

Thanks
 
when you say it doesnt work what do you mean?
does it give you an error?
does it tell you which line of code if failing?
does it update some fields but not others?
does the sql statement look correct when you echo it?
regards
richard
 
was there something you actually wanted to replace with this replace function?

Replace(Request.Form(&quot;message&quot;))

seems to be missing a parameter or two
eg:
Replace(Request.Form(&quot;message&quot;),&quot;something&quot;,&quot;something&quot;)

also the ASP forum would be more specific for this type of question forum333 [smile]

_____________________________________________________________________
Where have all my friends gone to????
onpnt2.gif

 
the connection string you are using is outdated and not a stable one either. try a oledb connection

_____________________________________________________________________
Where have all my friends gone to????
onpnt2.gif

 
I opened this page to check out what errors I am getting specifically, and it turned out that my replace function is missisg parameters. I added in the last 2 parameters and it works now. I also updates my connection string. Thatnk a lot for the help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top