您好我有一个gridview,链接到sqldatasource。我添加了一个存储过程以从多个表中删除,然后在gridviews智能标记上启用删除。
当我点击删除按钮时,我收到一条错误消息,“对象必须实现IConvertible”。我读到将参数传递给存储过程是一个问题,可能是传递了错误的数据类型。我不确定我是否将参数传递给存储过程。参数应该是gridviews datakeyname,在这种情况下它是“UserId”。
存储过程在管理工作室中工作得很好,所以我认为它只是传递的参数(或者可能没有被传递)
我是否必须在后面的代码中编码参数以传递给存储过程?
<asp:SqlDataSource ID="selectUsers" runat="server" ConnectionString="<%$ ConnectionStrings:CASSFConnectionString %>"
SelectCommand="SELECT aspnet_Membership.UserId, aspnet_Membership.IsLockedOut, aspnet_Membership.Email, aspnet_Membership.CreateDate, aspnet_Membership.LastLoginDate, aspnet_Membership.LastPasswordChangedDate, aspnet_Profile.PropertyValuesString, aspnet_Users.UserName, aspnet_Membership.IsApproved FROM aspnet_Membership INNER JOIN aspnet_Profile ON aspnet_Membership.UserId = aspnet_Profile.UserId INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId AND aspnet_Profile.UserId = aspnet_Users.UserId WHERE (CONVERT (nvarchar(256), aspnet_Profile.PropertyValuesString) = @district)"
DeleteCommand="DeleteUsers" DeleteCommandType="StoredProcedure" UpdateCommand="UPDATE [aspnet_Membership] SET [IsApproved] = @IsApproved, [Email] = @email, [IsLockedOut] = @IsLockedOut WHERE [aspnet_Membership].[UserId] = @UserID">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="district" PropertyName="SelectedValue" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="UserId" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="IsApproved" />
<asp:Parameter Name="email" />
<asp:Parameter Name="IsLockedOut" />
<asp:Parameter Name="UserID" />
</UpdateParameters>
</asp:SqlDataSource>
答案 0 :(得分:0)
找到答案,我刚从删除参数中删除Type="String"
。