Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Deleting a recordset???


Message #1 by "Marko Ramstedt" <marko.ramstedt@a...> on Wed, 4 Sep 2002 14:34:55
What is wrong with this code? No errors come, but no records
are deleted either :-(

Dim Conn 
Dim ConnStr 
Dim sSql
Dim sUsername

Set conn = Server.CreateObject("ADODB.Connection")
connStr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & 
Server.MapPath("/data/users_fin.mdb")
Conn.Open connStr

sUsername = Request.Form("txtUsername")

sSql="DELETE * FROM users UserName='" & sUsername & "' "

Conn.Execute sSql
Conn.Close
Set Conn=Nothing
Message #2 by "Marko Ramstedt" <marko.ramstedt@a...> on Wed, 4 Sep 2002 14:37:28
WHERE was missing from the sSql clause, but no change...

> What is wrong with this code? No errors come, but no records
a> re deleted either :-(

> Dim Conn 
D> im ConnStr 
D> im sSql
D> im sUsername

> Set conn = Server.CreateObject("ADODB.Connection")
c> onnStr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & 
S> erver.MapPath("/data/users_fin.mdb")
C> onn.Open connStr

> sUsername = Request.Form("txtUsername")

> sSql="DELETE * FROM users UserName='" & sUsername & "' "

> Conn.Execute sSql
C> onn.Close
S> et Conn=Nothing
Message #3 by "Drew, Ron" <RDrew@B...> on Wed, 4 Sep 2002 12:56:02 -0400
The WHERE clause is missing   DELETE * FROM users WHERE blah blah

-----Original Message-----
From: Marko Ramstedt [mailto:marko.ramstedt@a...]
Sent: Wednesday, September 04, 2002 10:35 AM
To: ASP Databases
Subject: [asp_databases] Deleting a recordset???

What is wrong with this code? No errors come, but no records
are deleted either :-(

Dim Conn
Dim ConnStr
Dim sSql
Dim sUsername

Set conn =3D Server.CreateObject("ADODB.Connection")
connStr =3D "DRIVER=3D{Microsoft Access Driver (*.mdb)}; DBQ=3D" &
Server.MapPath("/data/users_fin.mdb")
Conn.Open connStr

sUsername =3D Request.Form("txtUsername")

sSql=3D"DELETE * FROM users UserName=3D'" & sUsername & "' "

Conn.Execute sSql
Conn.Close
Set Conn=3DNothing
Message #4 by "Ken Schaefer" <ken@a...> on Thu, 5 Sep 2002 11:31:07 +1000
DELETE *

isn't quite correct either. DELETE * implies that you could also do DELETE
Field1, Field2 which you obviously can't - you can only delete an entire
record at a time:

DELETE
FROM
    TableName
WHERE
    <Condition>

is the "proper" way to write a delete query.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Drew, Ron" <RDrew@B...>
Subject: [asp_databases] RE: Deleting a recordset???


The WHERE clause is missing   DELETE * FROM users WHERE blah blah

-----Original Message-----
From: Marko Ramstedt [mailto:marko.ramstedt@a...]
Sent: Wednesday, September 04, 2002 10:35 AM
To: ASP Databases
Subject: [asp_databases] Deleting a recordset???

What is wrong with this code? No errors come, but no records
are deleted either :-(

Dim Conn
Dim ConnStr
Dim sSql
Dim sUsername

Set conn = Server.CreateObject("ADODB.Connection")
connStr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("/data/users_fin.mdb")
Conn.Open connStr

sUsername = Request.Form("txtUsername")

sSql="DELETE * FROM users UserName='" & sUsername & "' "

Conn.Execute sSql
Conn.Close
Set Conn=Nothing
---



  Return to Index