netsys
Posts: 39
|
Posted: 04/26/2010, 12:37 PM |
|
I need to add a SQL delete to custom code so that I can delete records in a related table after I delete the main record.
I want to delete all records in the Class_Times table that have Class_SchedID of the value of the query string Class_SchedID.
I put the following code into the "AfterDelete" function of the record. Based on the example of how to do a custom SQL insert, here's the code I came up with:
Dim SQL
Dim Connection
Dim ErrorMessage
Set Connection = New clsDBsafehunters
Connection.Open
SQL = "DELETE FROM Class_Times WHERE Class_SchedID='Request.QueryString("Class_SchedID")'"
Connection.Execute(SQL)
ErrorMessage = CCProcessError(Connection)
Connection.Close
Set Connection = Nothing
On Error Goto 0
When I run the page, I get this: Microsoft VBScript compilation error '800a0401'
Expected end of statement
/kansas/Create_A_Classteststeptwotesttwo_events.asp, line 82
SQL = "DELETE FROM Class_Times WHERE Class_SchedID='Request.QueryString("Class_SchedID")'"
-------------------------------------------------------------------------^
I'm assuming I've created my SQL statement wrong. Any ideas? Thanks.
|
|
|
mikebruyere
Posts: 2
|
Posted: 04/26/2010, 12:55 PM |
|
Is this something that you can do with a SQL Trigger? Seems like the easiest way to go.
|
|
|
netsys
Posts: 39
|
Posted: 04/26/2010, 12:58 PM |
|
Um, not really sure what a SQL trigger is.
|
|
|
robertmann
Posts: 109
|
Posted: 04/26/2010, 2:11 PM |
|
You have wrong quotes, prb should be SQL = "DELETE FROM Class_Times WHERE Class_SchedID=" + Request.QueryString("Class_SchedID")
and custom SQL Delete code is shown inside Store example.
DBInternetDB.Execute("DELETE FROM store_shopping_cart_items WHERE shopping_cart_id = " & DBInternetDB.ToSQL(Request.Cookies("shopping_cart_id"),ccsInteger) )
_________________
Robert |
|
|
netsys
Posts: 39
|
Posted: 04/26/2010, 2:20 PM |
|
Wonderful - that was it. Thank you for your help!
|
|
|
|