Timestamp in Webforms & Access

R

RoadKill

Okay, first off, our server doesn't seem to allow us to use the DRW or
FrontPage forms to connect to a database on our subwebs.

To get around that, I have coded my own forms. The problem I have is getting
the Timestamp to post to the Access database using the Insert command.

Any ideas?

Here is my code if that helps.

Thanks much!

<%@ Language = "VBScript"%>
<%
'Declare all local variables
dim conn
dim rs
dim strconn
dim strsql

strsql = ""
'set connection string to local variable-I use a DSN-less connection
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
Server.MapPath("fpdb/ReviewForm.mdb")


'build the sql statement based on the input from the form
strSQL = "INSERT INTO NewResults(Supervisor, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8,
Q9, Q10, User_name, ReviewType, Center) Values('" &
request.form("Supervisor") & "', '" & request.form("Q1") & "', '" &
request.form("Q2") & "', '" & request.form("Q3") & "', '" &
request.form("Q4") & "', '" & request.form("Q5") & "', '" &
request.form("Q6") & "', '" & request.form("Q7") & "', '" &
request.form("Q8") & "', '" & request.form("Q9") & "', '" &
request.form("Q10") & "', '" & request.form("User_name") & "', '" &
request.form("ReviewType") & "', '" & request.form("Center") & "')"



'Set connection object
set conn = server.createobject("adodb.connection")
conn.open strconn
'Use the execute method of the connection object the insert the record
conn.execute(strSQL)
conn.close
set conn = nothing
%>
 
S

Stefan B Rusynko

Presuming that your code now works as you posted:
1) Add a date time field to your database named say: PostedOn

2) Then add a hidden form field for the date/time using Now()
(See http://www.devguru.com/technologies/vbscript/quickref/now.html)
for the current server date/time to your form named the same as:

<input type="hidden" name="PostedOn", value="<%=Now()%>">

3) Modify your strSQL to add the date/time field (

strSQL = "INSERT INTO NewResults(Supervisor, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8,
Q9, Q10, User_name, PostedOn, ReviewType, Center) Values('" &
request.form("Supervisor") & "', '" & request.form("Q1") & "', '" &
request.form("Q2") & "', '" & request.form("Q3") & "', '" &
request.form("Q4") & "', '" & request.form("Q5") & "', '" &
request.form("Q6") & "', '" & request.form("Q7") & "', '" &
request.form("Q8") & "', '" & request.form("Q9") & "', '" &
request.form("Q10") & "', '" & request.form("User_name") & "', '" &
request.form("PostedOn") & "', '" &
request.form("ReviewType") & "', '" & request.form("Center") & "')"


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


Okay, first off, our server doesn't seem to allow us to use the DRW or
FrontPage forms to connect to a database on our subwebs.

To get around that, I have coded my own forms. The problem I have is getting
the Timestamp to post to the Access database using the Insert command.

Any ideas?

Here is my code if that helps.

Thanks much!

<%@ Language = "VBScript"%>
<%
'Declare all local variables
dim conn
dim rs
dim strconn
dim strsql

strsql = ""
'set connection string to local variable-I use a DSN-less connection
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
Server.MapPath("fpdb/ReviewForm.mdb")


'build the sql statement based on the input from the form
strSQL = "INSERT INTO NewResults(Supervisor, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8,
Q9, Q10, User_name, ReviewType, Center) Values('" &
request.form("Supervisor") & "', '" & request.form("Q1") & "', '" &
request.form("Q2") & "', '" & request.form("Q3") & "', '" &
request.form("Q4") & "', '" & request.form("Q5") & "', '" &
request.form("Q6") & "', '" & request.form("Q7") & "', '" &
request.form("Q8") & "', '" & request.form("Q9") & "', '" &
request.form("Q10") & "', '" & request.form("User_name") & "', '" &
request.form("ReviewType") & "', '" & request.form("Center") & "')"



'Set connection object
set conn = server.createobject("adodb.connection")
conn.open strconn
'Use the execute method of the connection object the insert the record
conn.execute(strSQL)
conn.close
set conn = nothing
%>
 
H

Hot-text

That why we be going to a Forum!

Stefan B Rusynko said:
Presuming that your code now works as you posted:
1) Add a date time field to your database named say: PostedOn

2) Then add a hidden form field for the date/time using Now()
(See http://www.devguru.com/technologies/vbscript/quickref/now.html)
for the current server date/time to your form named the same as:

<input type="hidden" name="PostedOn", value="<%=Now()%>">

3) Modify your strSQL to add the date/time field (

strSQL = "INSERT INTO NewResults(Supervisor, Q1, Q2, Q3, Q4, Q5, Q6, Q7,
Q8,
Q9, Q10, User_name, PostedOn, ReviewType, Center) Values('" &
request.form("Supervisor") & "', '" & request.form("Q1") & "', '" &
request.form("Q2") & "', '" & request.form("Q3") & "', '" &
request.form("Q4") & "', '" & request.form("Q5") & "', '" &
request.form("Q6") & "', '" & request.form("Q7") & "', '" &
request.form("Q8") & "', '" & request.form("Q9") & "', '" &
request.form("Q10") & "', '" & request.form("User_name") & "', '" &
request.form("PostedOn") & "', '" &
request.form("ReviewType") & "', '" & request.form("Center") & "')"


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


Okay, first off, our server doesn't seem to allow us to use the DRW or
FrontPage forms to connect to a database on our subwebs.

To get around that, I have coded my own forms. The problem I have is
getting
the Timestamp to post to the Access database using the Insert command.

Any ideas?

Here is my code if that helps.

Thanks much!

<%@ Language = "VBScript"%>
<%
'Declare all local variables
dim conn
dim rs
dim strconn
dim strsql

strsql = ""
'set connection string to local variable-I use a DSN-less connection
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
Server.MapPath("fpdb/ReviewForm.mdb")


'build the sql statement based on the input from the form
strSQL = "INSERT INTO NewResults(Supervisor, Q1, Q2, Q3, Q4, Q5, Q6, Q7,
Q8,
Q9, Q10, User_name, ReviewType, Center) Values('" &
request.form("Supervisor") & "', '" & request.form("Q1") & "', '" &
request.form("Q2") & "', '" & request.form("Q3") & "', '" &
request.form("Q4") & "', '" & request.form("Q5") & "', '" &
request.form("Q6") & "', '" & request.form("Q7") & "', '" &
request.form("Q8") & "', '" & request.form("Q9") & "', '" &
request.form("Q10") & "', '" & request.form("User_name") & "', '" &
request.form("ReviewType") & "', '" & request.form("Center") & "')"



'Set connection object
set conn = server.createobject("adodb.connection")
conn.open strconn
'Use the execute method of the connection object the insert the record
conn.execute(strSQL)
conn.close
set conn = nothing
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top