Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-20-2002, 09:15 PM   PM User | #1
BukHix
New to the CF scene

 
Join Date: Jun 2002
Location: Three Rivers, MI
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
BukHix is an unknown quantity at this point
Sending all Request.Form data in one step?

I have some code that allows me to take all the Request.Form data from any form and send it in an email with just these two lines of code:

FOR EACH el IN Request.Form
msg.appendtext( el & ": " & Request.form(el) & vbcrlf )

Is is possible to do the same thing when entering form data into a database. All the filed names are the same as the form field names. This is the code I am using.

Code:
FOR EACH el IN Request.Form
	msg.appendtext( el & ": " & Request.form(el) & vbcrlf )
	objRs.AddNew
	objrs(el) = request.form(el)
	objRs.Update
	objRs.Close
	Set objRs = Nothing
	objConn.Close
	Set objConn = Nothing
NEXT
If not msg.Send("mail.domain.com" ) then
    Response.write "<pre>" & msg.log & "</pre>"
Else
    Response.write "Message sent succesfully!"
	End if

Last edited by BukHix; 06-20-2002 at 09:21 PM..
BukHix is offline   Reply With Quote
Old 06-21-2002, 02:00 PM   PM User | #2
BukHix
New to the CF scene

 
Join Date: Jun 2002
Location: Three Rivers, MI
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
BukHix is an unknown quantity at this point
You were right about what I was really trying to do. I am still having trouble with the code. I took the email code out of it just to make it easier to troubleshoot. Here is what I have now:

Code:
<%
Const adLockOptimistic = 3
Const adCmdTable = &H0002
	
Dim objConn, objRs
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = _
	"DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & _
	Server.MapPath("/fpdb/maillist.mdb")

objConn.Open
Set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open "tblTest", objconn, ,adLockOptimistic , adCmdTable
objRs.AddNew		

FOR EACH el IN Request.Form
    objrs.Fields(el) = Request.Form(el)
NEXT
	objRs.Update
	objRs.Close
	Set objRs = Nothing
	objConn.Close
	Set objConn = Nothing
%>
All fields are text based and I am only trying this with four fields. This is the error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

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

/maillist/NewMail.asp, line 23

Last edited by BukHix; 06-21-2002 at 02:04 PM..
BukHix is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:29 PM.


Advertisement
Log in to turn off these ads.