简体   繁体   中英

Adding parameter to sqldatasource, How should i pass them to execute my stored procedure in asp.net

I am using a gridview where i am calling a stored procedure which has 4 input parameters.

Out of these 4 parameters, values are to be given such that

DomainId = This has to be the row which is to be deleted. This is a primary key

Domain = This field has to be passed to SP as NULL.

Description = This field has to be passed as NULL.

OperationType = This field has to be passed by programmer as some static value say 4

How to i need to specify these here...

More details of the Question are here .

Please help me out.

<DeleteParameters>
                        <asp:ControlParameter ControlID="GridView1" Name="DomainId" 
                            PropertyName="SelectedValue" Size="4" Type="Int32" />  
                        <asp:Parameter DefaultValue="" Name="Domain"  Size="16" Type="String" />
                        <asp:Parameter DefaultValue="" Name="Description" Type="String" />
                        <asp:Parameter DefaultValue="4" Name="OperationType" Type="Byte" />
                    </DeleteParameters>

On running my code using this

I gets an error

Procedure or Function 'spOnlineTest_Domain' expects parameter '@Domain', which was not supplied

you would need to prefix your parameter name with a "@"

your parameters would look like this instead.

<asp:Parameter DefaultValue="" Name="@Domain"  Size="16" Type="String" />
<asp:Parameter DefaultValue="" Name="@Description" Type="String" />
<asp:Parameter DefaultValue="4" Name="@OperationType" Type="Byte" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM