Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Deleting a record


Message #1 by "Neal Lebar" <nlebar@i...> on Wed, 17 Jan 2001 20:44:09 -0000
I'm missing something very obvious here... I've completed the add and

modify without much problem.  The delete took just a few minutes to

complete...however I'm getting a syntax error and I just can't find it. 

This has to be as easy as it gets.



By doing a response.write, here's what I get for my SQL string:



DELETE * from PressMaster Where ID = '123456789012345678901234567890'



The error that I'm getting is:...at the objCmd.Execute (below)



Error Type:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: 



Incorrect syntax near '*'.



I tried this SQL string in the SQL Query Analyzer and got the same error.



Here's the code:



'Build the SQL string

	strSQL = "DELETE * from PressMaster Where ID = '" & _

		Request.Form("cboPress") & "'"

	

	

	'Create and open the database object

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

	objConn.Open "DSN=Teledata_db"



	'Create the command object

	Set objCmd = Server.CreateObject("ADODB.Command")



	'Set the command object properties

	Set objCmd.ActiveConnection = objConn

	objCmd.CommandText = strSQL

	objCmd.CommandType = adCmdText



	'Execute the command

	

	Response.Write (strSQL) & "<br><br>"

	

	Response.Write (objCmd.CommandText)

	

	objCmd.Execute



	'End If	

	



'Close and dereference database objects



Set objCmd = Nothing

objConn.Close

Set objConn = Nothing



%>



Thanks for the help...



Neal

Message #2 by Ankur Kalsi <AnkurK@n...> on Wed, 17 Jan 2001 14:16:21 -0800
you do not need "*". The correct syntax is:



DELETE from PressMaster Where ID = '123456789012345678901234567890' 



AK

Message #3 by Imar Spaanjaars <Imar@S...> on Wed, 17 Jan 2001 23:48:36 +0100
Hehe, this is indeed as easy as it gets.... There is no such thing as DELETE *.

You either Delete it all, or you don't delete anything.

Try this instead:



'Build the SQL string

strSQL = "DELETE from PressMaster Where ID = '" & _

Request.Form("cboPress") & "'"





Also, make sure that Request.Form("cboPress") contains a value, by 

assigning it to a variable and checking that against "" or IsNull, for example.



HtH



Imar





At 08:44 PM 1/17/2001 +0000, you wrote:

>I'm missing something very obvious here... I've completed the add and

>modify without much problem.  The delete took just a few minutes to

>complete...however I'm getting a syntax error and I just can't find it.

>This has to be as easy as it gets.

>

>By doing a response.write, here's what I get for my SQL string:

>

>DELETE * from PressMaster Where ID = '123456789012345678901234567890'

>

>The error that I'm getting is:...at the objCmd.Execute (below)



Message #4 by "Wally Burfine" <oopconsultant@h...> on Wed, 17 Jan 2001 22:58:06 -0000
Try This:

DELETE PressMaster.ID

FROM PressMaster

WHERE (((PressMaster.ID)='123456789012345678901234567890'))





Also:

Is ID a varchar?

you normally think of ID with lots of numbers as a number but since it is so 

big a number it could be a string.



_________________________________________________________________

Get your FREE download of MSN Explorer at http://explorer.msn.com



Message #5 by "Neal Lebar" <nlebar@i...> on Wed, 17 Jan 2001 19:55:16 -0500
Thanks... that did the trick...



I got the code verbatum from Beginning ASP Databases, page 379.



As they say, don't believe everything you read!



Thanks again...



-----Original Message-----

From: Imar Spaanjaars [mailto:Imar@S...]

Sent: Wednesday, January 17, 2001 5:49 PM

To: ASP Databases

Subject: [asp_databases] Re: Deleting a record





Hehe, this is indeed as easy as it gets.... There is no such thing as DELETE

*.

You either Delete it all, or you don't delete anything.

Try this instead:



'Build the SQL string

strSQL = "DELETE from PressMaster Where ID = '" & _

Request.Form("cboPress") & "'"





Also, make sure that Request.Form("cboPress") contains a value, by

assigning it to a variable and checking that against "" or IsNull, for

example.



HtH



Imar





At 08:44 PM 1/17/2001 +0000, you wrote:

>I'm missing something very obvious here... I've completed the add and

>modify without much problem.  The delete took just a few minutes to

>complete...however I'm getting a syntax error and I just can't find it.

>This has to be as easy as it gets.

>

>By doing a response.write, here's what I get for my SQL string:

>

>DELETE * from PressMaster Where ID = '123456789012345678901234567890'

>

>The error that I'm getting is:...at the objCmd.Execute (below)




  Return to Index