...

View Full Version : Request.Form and Date issue



SteveH
01-07-2008, 02:39 PM
Hello

I have two small questions.

I have the following script which gathers variables from an online (Flash) form:

Dim conn,rs,SQL,myMail,name,email,business,country,message

name = Request.Form("name")
email = Request.Form("email")
business = Request.Form("business")
country = Request.Form("country")
message = Request.Form("message")

'Open MS Access database, store form field values, and close

The form data seems to take a long time for it to be sent after the 'Submit' button is pressed and I am writing to ask if it has anything to do with the above script.

Can I not simply write:

Request.Form("name")?

The other issue I have is that when the data is stored in my online database, the column for 'Date' is not completed with the date the form was sent. I thought this was done automatically. If not, how can I insert the date, please, preferably in the following format: 7th January 2008.

This is what I have at the moment:

SQL="INSERT INTO users (name, email, business, country, message) VALUES ('" & _
name & "', '" & email & "','" & business & "', '" & country & "', '" & message & "')"

Many thanks.

Steve

Whatever Jr.
01-07-2008, 03:19 PM
Hi,

the reason it's slow is probably because access isn't very good for webapplications.

You can fill the date column in your table by adding a default value to the column.
Refer to your access documentation on the exact syntax, I believe it is (Now())

HTH, Tom

SteveH
01-09-2008, 12:17 AM
Hello Whatever Jr

Thank you for your reply.

Now() returns the date and time and CurrDate = Date() the date only (I don't need the time).

But how would I code that in my ASP script?

Many thanks again for any advice.

Steve

Whatever Jr.
01-09-2008, 03:49 PM
Hi,

If you want to do it in ASP, then try this:


SQL="INSERT INTO users (name, email, business, country, message, date) VALUES ('" & _
name & "', '" & email & "','" & business & "', '" & country & "', '" & message & "', #" & Date() & "#)"


Or add in Access the default value (date()) to the column date'.

And I'm pretty sure 'date' is a reserved word in Access, so don't use it.

HTH, Tom

SteveH
01-12-2008, 07:03 PM
Hello Whatever Jr

Sorry but I get an error message when I use your statement:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

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

/ASPflash/flashEmailTest.asp, line 29

Any advise,\please?

Cheers

Steve

Spudhead
01-14-2008, 11:11 AM
Response.write() your generated SQL statement and post it up here.

SteveH
01-15-2008, 06:03 PM
Hello Spudhead

Many thanks for taking the time to reply.

I am not sure how to do that.

Is it:

Response.write="INSERT INTO users (name, email, business, country, message, date) VALUES ('" & _
name & "', '" & email & "','" & business & "', '" & country & "', '" & message & "', #" & Date() & "#)"

Then show/view the asp file?

Thanks

Steve

Whatever Jr.
01-16-2008, 10:30 AM
Try


response.write SQL


and view the page in your browser.

HTH, Tom

SteveH
01-16-2008, 11:26 PM
Hello Whatever Jr

I am getting this error msg now:

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/trial/flash.asp, line 88

"<dt>Message</dt>: <dd>" & MessageTitle & vbcrlf "</dd><br>
-----------------------------------------------------------^

I don't seem to be able to view the rsults of the response.writeSQL="INSERT INTO users (name, email, business, country, message) VALUES ('" & _
name & "', '" & email & "','" & business & "', '" & country & "', '" & message & "')"

while I have this error.

Does the error msg indicate the string has not been terminated correctly?

Cheers again.

Steve

SteveH
01-16-2008, 11:53 PM
I have managed to get this, Whatever Jr, unfortunately:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Response.writeSQL'

/ASPflash/flash.asp, line 22

Sorry to bother you again!

Steve

Whatever Jr.
01-17-2008, 07:35 AM
Hi,

There a variable, called SQL, that contains "INSERT INTO bla bla"

If you want to print that show in your browser, simply type:


response.write SQL


HTH, Tom

SteveH
01-17-2008, 01:40 PM
Hello Whatever Jr

When I type in:

response.write SQL

SQL="INSERT INTO users (name, email, business, country, message, date) VALUES ('" & _
name & "', '" & email & "','" & business & "', '" & country & "', '" & message & "', #" & Date() & "#)"

This is what I get in the browser:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

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

/trial/flash.asp, line 52

Do I need to 'dim' the date? I have not done so.

Also, in my database the sequence of fields is with 'date' at the beginning, not the end. Is that a possible source of problem?

Steve

Spudhead
01-17-2008, 04:10 PM
put the line

response.write SQL

AFTER the line

SQL="INSERT INTO users (name, email, business, country, message, date) VALUES ('" & _
name & "', '" & email & "','" & business & "', '" & country & "', '" & message & "', #" & Date() & "#)"



in fact... somwehere after this second line, you'll have another bit where you actually execute the SQL statement. It will look something like:

yourConnection.execute SQL

comment that out: put an apostrophe at the beginning of that line.

SteveH
01-19-2008, 05:42 PM
Hello Spudhead

I have done as you suggest, that is:

SQL="INSERT INTO users (name, email, business, country, message, date) VALUES ('" & _
'name & "', '" & email & "','" & business & "', '" & country & "', '" & message & "', #" & Date() & "#)"

response.write SQL

'rs.Open SQL, conn

and I get this:

http://stevehigham59.7host.com/trial/flash.asp

Is it looking for a pair of inverted commas?

Cheers

Steve

SteveH
01-21-2008, 01:23 PM
Hello Spudhead

I have done as you suggest, that is:

SQL="INSERT INTO users (name, email, business, country, message, date) VALUES ('" & _
'name & "', '" & email & "','" & business & "', '" & country & "', '" & message & "', #" & Date() & "#)"

response.write SQL

'rs.Open SQL, conn

and I get this:

http://stevehigham59.7host.com/trial/flash.asp

Is it looking for a pair of inverted commas?

Cheers

Steve



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum