Skip to main content
Participant
April 12, 2008
Question

Deleting a Record in Database - Error Message

  • April 12, 2008
  • 3 replies
  • 589 views
Hello.

I have made a database, where i can view, edit, add new records and its all working fine. I am trying to also have a delete feature on it. I have created the link for it to delete, and added the commands but im getting an error message when i hit delete saying :



"The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.

The following information is meant for the website developer for debugging purposes.

Error Occurred While Processing Request
Element DEPART is undefined in QARTIST.

"


i have looked through my coldfusion pages over and over but i cant see anything which is wrong and i cant figure out what line there might be a mistake on! could someone inform me what this error message is saying to me please?

Thanks very very very very much in advance
    This topic has been closed for replies.

    3 replies

    Inspiring
    April 12, 2008
    If you want to output query results, you use the name of the query, not the result.
    Inspiring
    April 12, 2008
    This is the line that failed.
    <td>#qArtists.Depart#</td>

    Before you get to that block of code, do this
    <cfdump var="#qArtists#">
    <cfabort>

    Do you have anything resembling Depart?
    Participant
    April 12, 2008
    Hello,

    I added that code above table code and now it shows everything in purple :
    query
    RESULTSET query
    ARTISTID BOARD DEPART FIRSTNAME HOTEL LASTNAME PRICE

    THEN ALL OF MY FIELD DATA..

    CACHED false
    EXECUTIONTIME 16
    SQL SELECT ArtistID, FirstName, LastName, Depart, Hotel, Board, Price FROM artists ORDER BY LastName ASC

    Im not too sure what you mean by do i 'have something resembling Depart'? could you explain please?

    Thanks very much for trying to help me!

    Alex

    Participant
    April 12, 2008
    Getting really confused now. I think it could have something to do with my variables, how do i check what my current variables are as i just found :

    <cfset variables.pageTitle="OK to delete " & variables.artistName & "?">
    <cfinclude template="../includes/header.cfm">

    and im wondering if i need to add the other rows in there?

    i have uploaded the pages/code to here :

    http://www.uploading.com/files/AE2H4NWU/artistpage.rar.html

    if that makes it easier for u to see what i have done wrong...

    Inspiring
    April 12, 2008
    The error message indicates a missing variable. It could be depart, or it could be qartist. The error message is the same in both cases.
    Participant
    April 12, 2008
    Hello.

    Thanks very much for the response!

    I have searched more on the missing variable but still cant work out whats wrong.

    Not sure why its saying 'depart' specfically as that is the 3rd row in the table.

    Not too sure on where to go frm here. Could i ask for a bit more specific help?

    I have 3 an index page which displays the 7 rows + a link to edit any of the returned data :


    <td>#qArtists.CurrentRow#</td>
    <td>#qArtists.FirstName#</td>
    <td>#qArtists.LastName#</td>
    <td>#qArtists.Depart#</td>
    <td>#qArtists.Hotel#</td>
    <td>#qArtists.Board#</td>
    <td>#qArtists.Price#</td>
    <td><a href="updateartist.cfm?artistid=#qArtists.ArtistID#">Edit</a></td>


    Then i have a :
    artist.cfc which i added the delete code to :


    <cffunction name="deleteArtist" access="public" returntype="void">
    <cfargument name="artistid" type="numeric" required="yes">

    <cfquery datasource="#application.datasource#">
    DELETE FROM artists
    WHERE ArtistID = #arguments.artistid#
    </cfquery>

    </cffunction>


    then i have a delete.cfm file

    <cfif IsDefined("form.artistid")>
    <cfinvoke
    component="cf8essentials.cfc.Artist"
    method="deleteArtist">
    <cfinvokeargument name="artistid" value="#form.artistid#"/>
    </cfinvoke>
    <cflocation url="/cf8essentials/artists/index.cfm" addtoken="no">
    </cfif>

    <cfform>
    <cfinput type="submit" name="submit" value="Delete">
    <cfinput type="button" name="cancel" value="Cancel"
    onclick="history.back()">
    <cfinput type="hidden" name="artistid" value="#url.artistid#">
    </cfform>


    really not sure what part im doing wrong as i have fllowed two different tutorials which do it different and both of theirs work but im not sure what ive done wrong. Could you advise further has ive been pulling my hair out over this for the past couple of days now! thanks very much in advance again!