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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating Date and Number fields

Status
Not open for further replies.
Joined
Jan 27, 2003
Messages
9
Location
US
I'm new to ASP so I'll apologize in advance for not being able to figure this out. I can't get my update statement to work when I include either a date or a number field. Here's the code:

<%
Dim ID, status, results, tester, notes, timestamp
ID= Request.Form(&quot;ID&quot;)
status= Request.Form(&quot;status&quot;)
results= Request.Form(&quot;results&quot;)
tester= Request.Form(&quot;tester&quot;)
notes= Request.Form(&quot;notes&quot;)
timestamp= Request.Form(&quot;timestamp&quot;)
if tester=&quot;&quot; OR notes=&quot;&quot; then
Response.Write &quot;Either the Testers Name or the Notes field were left empty, please try again!&quot;
Else
Dim Conn , Rs, sql
Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set Rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Conn.Open &quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot; & Server.MapPath(&quot;sr6.mdb&quot;)
sql= &quot;Update tbldts Set status = '&quot; & status & &quot;', results='&quot; & results &&quot;', tester='&quot; & tester &&quot;', notes ='&quot; & notes &&quot;', timestamp='&quot; & timestamp &&quot;' WHERE index=&quot;&ID
Rs.Open sql, Conn
Conn.Close
Set Rs=Nothing
Set Conn = Nothing
Response.Write &quot;Successfully Updated&quot;
End If
%>

The timestamp field is a date and whenever I take it out of the update statement it works. Any help would be greatly appreciated. Thanks.
 
the format of the variable &quot;timestamp&quot; is important.

This is nice to see how you can fill a datetime field in SQL

DROP TABLE X
GO
SET NOCOUNT ON
CREATE TABLE X(D DATETIME)

INSERT INTO X VALUES ('19561030')
INSERT INTO X VALUES ('561030')
INSERT INTO X VALUES ('10/30/1956')
INSERT INTO X VALUES ('10/30/56')
INSERT INTO X VALUES ('30 OCT 1956')
INSERT INTO X VALUES ('30 OCT 56')
INSERT INTO X VALUES ('OCT 30 1956')
INSERT INTO X VALUES ('OCT 30, 1956')
INSERT INTO X VALUES ('OCT 30, 56')
INSERT INTO X VALUES ('OCTOBER 10, 1956')
SELECT * FROM X




hth,
Foxbox
ttmug.gif
 
Ok, so timestamp is in the default Now() format of 2/5/2004 2:14:07 PM

I use the Now() function to automatically populate timestamp but I don't know how to update the database with this value.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top