Groups | Blog | Home
all groups > inetserver asp db > march 2007 >

inetserver asp db : Help- Add, Update and Delete using ASP for MS Access


crab.dae NO[at]SPAM gmail.com
3/5/2007 1:14:22 PM
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
3/6/2007 2:35:24 PM
[quoted text, click to view]


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

.....




AddThis Social Bookmark Button