gpt4 book ai didi

asp.net - 无法从网格更新表(过程或函数 spExcelGridTestUpdateTable 指定的参数太多)

转载 作者:行者123 更新时间:2023-12-02 03:42:36 25 4
gpt4 key购买 nike

在“保存”命令中,我试图在类似 Excel 的网格中更新多个已编辑的行,其列如下所示:

<Columns>
<telerik:GridNumericColumn DataField="CarID" DataType="System.Int32" HeaderText="ID"
SortExpression="CarID" UniqueName="CarID" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo" HeaderStyle-Width="100" ItemStyle-Width="100" FilterControlWidth="60" ReadOnly="false"/>
<telerik:GridBoundColumn DataField="CarMake" DataType="System.String" HeaderText="Car Make"
SortExpression="CarMake" UniqueName="CarMake" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" HeaderStyle-Width="120" ItemStyle-Width="120" FilterControlWidth="80" />
<telerik:GridBoundColumn DataField="CarModel" DataType="System.String" HeaderText="Car Model"
SortExpression="CarModel" UniqueName="CarModel" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" HeaderStyle-Width="120" ItemStyle-Width="120" FilterControlWidth="80" />
<telerik:GridBoundColumn DataField="CarTrim" DataType="System.String" HeaderText="Car Trim"
SortExpression="CarTrim" UniqueName="CarTrim" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" HeaderStyle-Width="200" ItemStyle-Width="200" FilterControlWidth="160"/>
<telerik:GridNumericColumn DataField="CarYear" DataType="System.Int32" HeaderText="Car Year"
SortExpression="CarYear" UniqueName="CarYear" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo" HeaderStyle-Width="100" ItemStyle-Width="100" FilterControlWidth="60" />

这是我的“保存”命令:

Case "Save" 
For Each editedItem As GridEditableItem In RadGridViewExcelGridTest.EditItems
Dim newValues As Hashtable = New Hashtable
'The GridTableView will fill the values from all editable columns in the hash
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem)
SqlDataSourceExcelGridTest.UpdateCommandType = SqlDataSourceCommandType.StoredProcedure
SqlDataSourceExcelGridTest.UpdateCommand = "spExcelGridTestUpdateTable"
SqlDataSourceExcelGridTest.UpdateParameters.Add(New Parameter("CarID", DbType.Int32))
SqlDataSourceExcelGridTest.UpdateParameters.Add(New Parameter("CarMake", DbType.String))
SqlDataSourceExcelGridTest.UpdateParameters.Add(New Parameter("CarModel", DbType.String))
SqlDataSourceExcelGridTest.UpdateParameters.Add(New Parameter("CarTrim", DbType.String))
SqlDataSourceExcelGridTest.UpdateParameters.Add(New Parameter("CarYear", DbType.Int32))
SqlDataSourceExcelGridTest.Update()
editedItem.Edit = False
Next

我的存储过程如下所示:

ALTER PROCEDURE [dbo].[spExcelGridTestUpdateTable] 
-- Add the parameters for the stored procedure here
@CarID int,
@CarMake varchar(100),
@CarModel varchar(100),
@CarTrim varchar (100),
@CarYear int

AS
BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

UPDATE [dbo].[TestTable_Cars]
SET CarMake=@CarMake, CarModel=@CarModel, CarTrim=@CarTrim, CarYear=@CarYear
WHERE CarID=@CarID
END

我遇到的错误是过程或函数 spExcelGridTestUpdateTable 指定的参数太多。大多数遇到此错误的人似乎只是在涉及其中一个参数名称时有错别字,但我已经检查过并且一切似乎都一致。如果我从 SQLServer 执行 SP 并提供参数(或传递 NULL 参数),SP 运行良好。

最佳答案

尝试添加

SqlDataSourceExcelGridTest.UpdateParameters.Clear()

之前

SqlDataSourceExcelGridTest.UpdateParameters.Add(New Parameter("CarID", DbType.Int32)) 

关于asp.net - 无法从网格更新表(过程或函数 spExcelGridTestUpdateTable 指定的参数太多),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19168622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com