I got an error message on trying to insert a row to a table with an identity 
column using cfgrid onchange
I would like also to use a stored procedure instead of cfquery I just need how 
to call it and how to pass arguments to it
Please look below is the code,component, and error message
     My component
    
<!--- Edit a Media Type  --->
    <cffunction name="cfn_MediaType_Update" access="remote">
        <cfargument name="gridaction" type="string" required="yes">
        <cfargument name="gridrow" type="struct" required="yes">
        <cfargument name="gridchanged" type="struct" required="yes">

        <!--- Local variables --->
        <cfset var colname="">
        <cfset var value="">

        <!--- Process gridaction --->
        <cfswitch expression="#ARGUMENTS.gridaction#">
            <!--- Process updates --->
            <cfcase value="U">
                <!--- Get column name and value --->
                <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                <cfset value=ARGUMENTS.gridchanged[colname]>
                <!--- Perform actual update --->
               
                
                <cfquery datasource="#application.dsn#">
                UPDATE SP.MediaType
                SET #colname# = '#value#'
                WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                </cfquery>
            </cfcase>
            <!--- Process deletes --->
            <cfcase value="D">
                <!--- Perform actual delete --->
                <cfquery datasource="#application.dsn#">
                update SP.MediaType 
                set Deleted=1
                WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                </cfquery>
            </cfcase>
            <cfcase value="I">
                <!--- Get column name and value --->
                <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                <cfset value=ARGUMENTS.gridchanged[colname]>
              
                <!--- Perform actual update --->

               <cfquery datasource="#application.dsn#">
                insert into  SP.MediaType (#colname#)
                Values ('#value#')               
                </cfquery>
            </cfcase>
        </cfswitch>
    </cffunction>
---------------------------------------------------
my table
mediatype:
mediatypeid primary key,identity
mediatypename 
________________________________
my code is
<cfform method="post" name="GridExampleForm">
        
                    
        <cfgrid format="html" name="grid_Tables2" pagesize="3"  
selectmode="edit" width="800px"  
        delete="yes"
        insert="yes"
        
                        
          bind="cfc:sp3.testing.MediaType.cfn_MediaType_All
                                        
({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
              
onchange="cfc:sp3.testing.MediaType.cfn_MediaType_Update({cfgridaction},
                                            {cfgridrow},
                                            {cfgridchanged})">
            
            <cfgridcolumn name="MediaTypeID" header="ID"  display="no"/>
            <cfgridcolumn name="MediaTypeName" header="Media Type" />
            
        </cfgrid>
        
</cfform>
__________________________________
on insert I get the following error message ajax logging error message
http: Error invoking xxxxxxx/MediaType.cfc : Element '' is undefined in a CFML 
structure referenced as part of an expression.
{"gridaction":"I","gridrow":{"MEDIATYPEID":"","MEDIATYPENAME":"uuuuuu","CFGRIDROWINDEX":4},"gridchanged":{}}
____________________________________________




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333805
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to