Help- Add, Update and Delete using ASP for MS Access
am 05.03.2007 22:14:22 von crab.dae
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
%>
Re: Help- Add, Update and Delete using ASP for MS Access
am 06.03.2007 15:35:24 von John Blessing
wrote in message
news:1173129262.016140.4700@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
.....