FP database - trying to delete records (manual asp)

M

mettá

I can't get this working, I have tried to adapt a bit of asp script that
shows db results and use it to delete specific records (via a form on
another page)

spage is text field
idp is auto number record id

<%Dim DSN_Name
DSN_Name = Application("dbpages_ConnectionString")
set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open DSN_Name
Search=Request("Description")
Set RSCat = Server.CreateObject("ADODB.RecordSet")
SQL = "DELETE DISTINCT from tPages WHERE idp=::idp:: and spage='::spage::'"
RSCat.Open SQL, Connection
RSCat.Close
%>

I would really appreciate some guidance as I do not really know what I am
doing!

Thanks
M
 
M

mettá

Sorry I copied the wrong bit - what I have tried is

<%Dim DSN_Name
DSN_Name = Application("dbpages_ConnectionString")
set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open DSN_Name
Set RSCat = Server.CreateObject("ADODB.RecordSet")
SQL = "DELETE DISTINCT from tPages WHERE idp=::idp:: and spage='::spage::'"
RSCat.Open SQL, Connection
RSCat.MoveNext
wend
RSCat.Close
%>

Thanks
M
 
S

Stefan B Rusynko

1) The values of neither idp or spage are defined in your code snippet
SQL = "DELETE DISTINCT from tPages WHERE idp=::idp:: and spage='::spage::'"

Before the SQL you need to add them if passed from a form as say:
spage=Request.form("spage")
idp=Request.form("idp")

And then all you should need is:

<%
Dim spage, idp
spage=Request.form("spage")
idp=Request.form("idp")
IF Len(spage)>0 AND Len(idp)>0 THEN
Dim DSN_Name, Connection, Set RSCat, SQL
DSN_Name = Application("dbpages_ConnectionString")
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open DSN_Name
Set RSCat = Server.CreateObject("ADODB.Recordset")
SQL = "DELETE * from tPages WHERE idp=" & idp & " AND spage='" & spage & "'"
RSCat.Open SQL, Dim DSN_Name
Connection.Close
Set Connection = Nothing
END IF
%>


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


Sorry I copied the wrong bit - what I have tried is

<%Dim DSN_Name
DSN_Name = Application("dbpages_ConnectionString")
set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open DSN_Name
Set RSCat = Server.CreateObject("ADODB.RecordSet")
SQL = "DELETE DISTINCT from tPages WHERE idp=::idp:: and spage='::spage::'"
RSCat.Open SQL, Connection
RSCat.MoveNext
wend
RSCat.Close
%>

Thanks
M
 
M

mettá

Thanks for that, I got it going with a few adjustments and now want to be
able to update a record (separate post)


M



Stefan B Rusynko said:
1) The values of neither idp or spage are defined in your code snippet
SQL = "DELETE DISTINCT from tPages WHERE idp=::idp:: and
spage='::spage::'"

Before the SQL you need to add them if passed from a form as say:
spage=Request.form("spage")
idp=Request.form("idp")

And then all you should need is:

<%
Dim spage, idp
spage=Request.form("spage")
idp=Request.form("idp")
IF Len(spage)>0 AND Len(idp)>0 THEN
Dim DSN_Name, Connection, Set RSCat, SQL
DSN_Name = Application("dbpages_ConnectionString")
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open DSN_Name
Set RSCat = Server.CreateObject("ADODB.Recordset")
SQL = "DELETE * from tPages WHERE idp=" & idp & " AND spage='" & spage
& "'"
RSCat.Open SQL, Dim DSN_Name
Connection.Close
Set Connection = Nothing
END IF
%>


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


Sorry I copied the wrong bit - what I have tried is

<%Dim DSN_Name
DSN_Name = Application("dbpages_ConnectionString")
set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open DSN_Name
Set RSCat = Server.CreateObject("ADODB.RecordSet")
SQL = "DELETE DISTINCT from tPages WHERE idp=::idp:: and
spage='::spage::'"
RSCat.Open SQL, Connection
RSCat.MoveNext
wend
RSCat.Close
%>

Thanks
M




mettá said:
I can't get this working, I have tried to adapt a bit of asp script that
shows db results and use it to delete specific records (via a form on
another page)

spage is text field
idp is auto number record id

<%Dim DSN_Name
DSN_Name = Application("dbpages_ConnectionString")
set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open DSN_Name
Search=Request("Description")
Set RSCat = Server.CreateObject("ADODB.RecordSet")
SQL = "DELETE DISTINCT from tPages WHERE idp=::idp:: and
spage='::spage::'"
RSCat.Open SQL, Connection
RSCat.Close
%>

I would really appreciate some guidance as I do not really know what I am
doing!

Thanks
M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top