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

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
%>
crab.dae [ Mo, 05 März 2007 22:14 ] [ ID #1648007 ]

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

<crab.dae [at] gmail.com> wrote in message
news:1173129262.016140.4700 [at] 64g2000cwx.googlegroups.com...
> 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
> %>


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

.....
John Blessing [ Di, 06 März 2007 15:35 ] [ ID #1649213 ]
Webserver » microsoft.public.inetserver.asp.db » Help- Add, Update and Delete using ASP for MS Access

Vorheriges Thema: Invalid class string error
Nächstes Thema: Warning user before db update