Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / March 2007



Tip: Looking for answers? Try searching our database.

Help- Add, Update and Delete using ASP for MS Access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
crab.dae@gmail.com - 05 Mar 2007 21:14 GMT
Need a little help please.  I've got the below to add records to a
table, but I need to learn how to do updates and deletes.

Could someone give me examples of how to update and delete a record
based on the below?

For update, I'd like an example on how to update the Location based on
frm_cname.  For delete, I'd like to see an example of how to delete
the row based on frm_cname.

Thanks!!
===============================

<%
Dim objCommand
Dim objRec
Set objCommand = Server.CreateObject ("ADODB.Command")
Set objRec = Server.CreateObject ("ADODB.Recordset")

strConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=d:\www
\signup.mdb"

objRec.Open "tablename", strConnect, 3, 3, 2

   objRec.AddNew
   objRec("TIME") = Now()
   objRec("LOCATION") = Request.Form("frm_loc")
   objRec("CLIENT") = Request.Form("frm_cname")

   objRec.Update

   objRec.Close
   Set objRec = Nothing
   Set objCommand = Nothing
%>
John Blessing - 06 Mar 2007 14:35 GMT
> Need a little help please.  I've got the below to add records to a
> table, but I need to learn how to do updates and deletes.
[quoted text clipped - 31 lines]
>    Set objCommand = Nothing
> %>

Aircode, might need a bit of fixing up but you should get the general idea

set objconn = server.create ("adodb.connection")

...
objconn.open strconnect
objconn.execute ("delete from table where recordid=" & cstr(yourid)
...

objconn.execute ("update yourtable set column=" & yourval & " where
recordid=" & cstr(yourid)
or
objconn.execute ("update yourtable set column='" & yourcharval & "' where
recordid=" & cstr(yourid)
or
objrec.Open "Select col from yourtable where recordid=" & cstr(yourid),
objconn

objrec.fields("col") = yournewval
objrec.update

....
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.