View Single Post
  #5 (permalink)  
Old March 24th, 2006, 11:34 AM
kshort kshort is offline
Registered User
 
Join Date: Mar 2006
Location: , , United Kingdom.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was returning it by the return value of the stored procedure, which can be be got hold of by using the RETURN_VALUE parameter available through the sqldatasource. It didn't matter which way I did it, that way, or by declaring an output parameter as you suggest, for the delete (and ONLY the delete) it didn't work.


I've discovered what the problem was, but I'm still rather confused as to why it's happening.

The reason I'm getting a null value for the return parameter is that somewhere along the line @ERR is being reset to a STRING INPUT parameter, despite the fact that I'm creating it as an INT32 OUTPUT parameter. It's an int output in the source code, or if I look at the delete query parameters it's definitely an int32 output there.

        <DeleteParameters>
            <asp:Parameter Name="yID" Type="Int32" />
            <asp:Parameter Direction="Output" Name="ERR" Type="Int32" />
        </DeleteParameters

But when I look at the e.command.parameters in the datasource deleting or deleted event, @ERR is a string input parameter, and its value is null.

I can reset @ERR back to being an int32 output parameter in the deleting event:

            SqlParameter outParam = (SqlParameter)e.Command.Parameters["@ERR"];
            outParam.SqlDbType = SqlDbType.Int;
            outParam.Direction = ParameterDirection.Output;
            e.Command.Parameters["@ERR"] = outParam;

Does anyone know why this is happening? The select/update/insert don't do this – @ERR stays an int output parameter with them - only the delete. The update & delete event are fired from the gridview, the insert from a button & textbox. Everything was just dragged onto the page from the toolbox and (as far as I know) I haven't set anything unusual. This is happening on every page with a sqldatasource & gridview (8 so far).

Any suggestions?





Reply With Quote