Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - updating my database from asp page
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

updating my database from asp page

 Post Reply Post Reply
Author
t4p67b96 View Drop Down
Newbie
Newbie


Joined: 10 May 2005
Location: United States
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote t4p67b96 Quote  Post ReplyReply Direct Link To This Post Topic: updating my database from asp page
    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
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post 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


Edited by ub3rl337ch3ch - 10 May 2005 at 7:25pm
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
t4p67b96 View Drop Down
Newbie
Newbie


Joined: 10 May 2005
Location: United States
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote t4p67b96 Quote  Post ReplyReply Direct Link To This Post 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=" & "\\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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.