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
%>
 
Ad

Advertisements

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
%>
 
Ad

Advertisements

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
%>
 

Similar threads

R
Replies
3
Views
1K
Stefan B Rusynko
S
R
Replies
1
Views
897
Stefan B Rusynko
S
J
Replies
3
Views
122
Dave Peterson
D
E
Replies
7
Views
189
RagDyeR
R
J
Replies
0
Views
102
JOM
J
J
Replies
0
Views
199
JOM
J
M
Replies
1
Views
112
mrice
M
N
Replies
2
Views
135
Jeff Boyce
J
Top