Print Page | Close Window

updating my database from asp page

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=15013
Printed Date: 30 March 2026 at 5:05am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: updating my database from asp page
Posted By: t4p67b96
Subject: updating my database from asp page
Date Posted: 10 May 2005 at 2:08pm
I'm not sure what code or how to set up my asp form page so when my users enter data it will overwrite the data in my access tables from the day before.  I really don't need to keep records more than a day.
 
Thanks
 
t4p67b96



Replies:
Posted By: michael
Date Posted: 10 May 2005 at 4:00pm
Well it should not really matter how the form is setup, but more how you type the SQL.
 
Unfortunately the current version of SQL Server does not have a UpdateOrInsert Method, neither of course does access. If you can post some details on how the table is structured it would be much easier to post you an example.


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: ub3rl337ch3ch
Date Posted: 10 May 2005 at 7:19pm
you could just set it up so that the form does normal insert, but whenever it posts it also checks for any records from more than, say, three days ago.
 
like so:
 
sql = "INSERT ......"
adoCon.Execute sql
 
vDate = DateAdd(d,-3,Now)
sql = "DELETE FROM theTable WHERE theDate <='" & vDate & "'"
adoCon.Execute sql
 
so every time something is posted, any records from 3 or may days ago are deleted.
 
just set up your table so that it has a date/time field with a default value of Now(), so it's just a timestamp. If you only want to keep stuff for 24 hours then do:
 
vDate = DateAdd(h,-24,Now)
sql = "DELETE FROM theTable WHERE theDate < '" & vDate & "'"
adoCon.Execute sql


Posted By: dpyers
Date Posted: 10 May 2005 at 10:50pm
It would be a good thing to do a daily compact and repair if your doing a lot of deleting.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: t4p67b96
Date Posted: 11 May 2005 at 8:18am
Below is what I have now on the "action" page.  The 1st page is just a basic form with submit.
 
%>
Dim datein, accidents, ogpriority
 
datein = Request.Form("dte")
accidents= Request.Form("Accidents")
ogpriorityoh =Request.Form("PL1oh")

'open database create recordset

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.ConnectionString = "Data Source=" & " file://\\test\test_data\plants\dcprov.mdb - \\test\test_data\plants\dcprov.mdb "
Conn.Open
Set rst = Server.CreateObject("ADODB.Recordset")
rst.Open "dcprov", Conn, 1, 3

rst.AddNew
rst("Date") = now()
rst("Accidents") = accidents
rst("OG Priority OH") = ogpriorityoh

Rst.Update
Rst.MoveLast
%>
 
 
t4p67b96



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net