Skip to main content
Participant
May 14, 2010
Question

cfgridbinding and storedprocedure

  • May 14, 2010
  • 1 reply
  • 872 views

I am not able to use cfgrid bind to a method that uses a stored procedure

If I used the grid without the bind it works find

Appreciate your help

my stored procedure is as follows. It works fine by itself

CREATE

PROCEDURE [dbo].[usp_myproc]

(

@SectionID

int,

@gridsortcolumn

nvarchar(30),

@gridsortdirection

nchar(4)

)

begin

xxxxxx

end

______________________

my component is

section.cfc

has the following function

<cffunction name="cfn_myfunction"

output="yes"

returntype="query"

access="remote">

<cfargument name="SectionID" type="numeric" required="yes">

<cfargument name="gridsortcolumn" type="string" required="yes">

<cfargument name="gridsortdirection" type="string" required="yes">

<cfstoredproc

procedure="usp_myproc"

datasource="#application.dsn#" returncode="no" >

<cfprocparam value="#arguments.SectionID#"

type="in"

cfsqltype="cf_sql_integer"

null="no">

<cfprocparam value="#arguments.gridsortcolumn#"

type="in"

cfsqltype="cf_sql_varchar"

null="no">

<cfprocparam value="#arguments.gridsortdirection#"

type="in"

cfsqltype="cf_sql_varchar"

null="no">

<cfprocresult name = "RS_myproc">

</cfstoredproc>

<cfreturn queryConvertForGrid(RS_myproc, page, pageSize) />

</cffunction>

_____________________________________________________

my cfm page is as follows

<cfform name="tryme">

<cfgrid name="mygrid",

format="html",

sort="yes",

bind="cfc:component.data.section.cfn_myfunc ({cfgridpage},{cfgridpagesize},

{cfgridsortcolumn},{cfgridsortdirection})",

pagesize="7" ,

selectmode="row">

<cfgridcolumn name="UserID" display="No"/>

<cfgridcolumn name="FIRSTNAME" header="FIRST NAME" >

<cfgridcolumn name="LASTNAME" header="LAST NAME" >

<cfgridcolumn name="Email" header="Email" >

</cfgrid>

</cfform>

______________________________

it does not work

It works if I used an embedded query instead of the stored procedure

how can I resolve that

    This topic has been closed for replies.

    1 reply

    Inspiring
    May 14, 2010

    First, you need to tell us what you mean by "it does not work". Does an error occur, you get the wrong results, nothing at all happens ...?

    Participant
    May 14, 2010

    Ajax error message saying that error in querying the database. Although the stored procedure works fine and it works fine with the grid if I did not use the bind attribute

    Can you send me a link for an example on how to use the cfgrid bind attribute with a component's method that uses a storedprocedure (not a query) with arguments.

    Thanks

    Inspiring
    May 14, 2010

    I suspect that is not the actual code you are using. As there are some syntax errors that would prevent it from compiling (commas between attributes and missing arguments for the cffunction). Can you post the actual cfgrid and cffunction code you are using, with all arguments?

    Also, if you check the ajax console, what arguments are being passed?  It should look something like:

            CFC: /component/data/section.cfc , function:  cfn_Section_StudentRoster_forgrid, arguments:  { ..... }

    If you call the stored procedure with those  arguments, does it succeed or fail?

    Message was edited by: -==cfSearching==-