PDA

View Full Version : deleteing from access datebase


Phip
09-05-2002, 11:18 PM
I can't figure this out it deletes like it should but i still get an error.


<%

Dim adoCon
Dim strSQL
Dim rsDelete
Dim intIdNum
Dim rsCheck

intIdNum = Request.QueryString("id")

Set adoCon = Server.CreateObject("ADODB.Connection")

adoCon.Open "DSN=newsAccess"

strSQL = "DELETE FROM newspost WHERE id IN(" & intIdNum & ")"

Set rsCheck = Server.CreateObject("ADODB.Recordset")

Set rsDelete = adoCon.Execute(strSQL)

rsDelete.Close
adoCon = Nothing

%>

raf
09-06-2002, 10:40 AM
i'm not sure, buth since nobody else reacts ...

my code would look a lot different. Why do you need those recordsets ?

my code (i presume the ID is a variable of datatype number. if it is of text datatype, then you have to replacte andID by 'anID' in strSQL ):

<%

Dim adoCon
Dim strSQL

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DSN=newsAccess"

strSQL = "DELETE * FROM newspost WHERE id =anID"
strSQL=replace(strSQL,"anID",Request.QueryString("id") )

adoCon.Execute strSQL

adoCon.Close
adoCon = Nothing

%>


I'm not sure about your adoCon.open line buth the rest should work fine