CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Custom Code SQL delete

Print topic Send  topic

Author Message
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.
View profile  Send private message
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.
View profile  Send private message
netsys

Posts: 39
Posted: 04/26/2010, 12:58 PM

Um, not really sure what a SQL trigger is.
View profile  Send private message
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
View profile  Send private message
netsys

Posts: 39
Posted: 04/26/2010, 2:20 PM

Wonderful - that was it. Thank you for your help!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.