我创建了一个网络应用。现在,我遇到了问题。我使用Grid with checkbox。我有一个场景,当用户选择要保存在数据库中的数据时,他们勾选网格中的复选框。现在,问题出在我保存数据的时候。保存需要3-5分钟。有没有其他方法来优化它?这是我的代码
For Each oGridItem In dgObj.Items
Dim oCheck As CheckBox = oGridItem.FindControl("chkSelect1")
If oCheck.Checked = True Then
Try
If AppType.Text = 124 Then
WebCtrl.strCommand = "EXEC spFilterUnLiquidation '" & AppType.Text & "', '" & GetGridItem("AppId").Text & "', '" & dgObj.DataKeys(oGridItem.ItemIndex) & "', '" & GetCompanyId & "' SET DATEFORMAT mdy EXEC spUpdateUnliquidate '" & GetGridItem("AppId").Text & "', '" & dgObj.DataKeys(oGridItem.ItemIndex) & "', " & GetGridItem("DiffAmnt").Text & ", '" & GetCompanyId & "' "
Else
WebCtrl.strCommand = "EXEC spFilterLiquidation '" & AppType.Text & "', '" & GetGridItem("AppId").Text & "', '" & dgObj.DataKeys(oGridItem.ItemIndex) & "', '" & GetCompanyId & "' "
End If
Catch Exp As Exception
WebCtrl.SetMessage(Exp)
GoTo RollBack
End Try
WebCtrl.strCommand = "SELECT AppId FROM _temp WHERE AppId = '" & GetGridItem("AppId").Text & "' "
If WebCtrl.dsCount() > 0 Then
WebCtrl.strCommand = "DELETE FROM _temp WHERE Liquidator = '" & txtLiqId.Text & "' "
WebCtrl.strCommand = "INSERT INTO _temp SELECT * FROM APP_OCAE WHERE AppId = '" & GetGridItem("AppId").Text & "' "
Else
WebCtrl.strCommand = "INSERT INTO _temp SELECT * FROM APP_OCAE WHERE AppId = '" & GetGridItem("AppId").Text & "' "
End If
WebCtrl.strCommand = "SELECT AppId FROM _temp1 WHERE AppId = '" & GetGridItem("AppId").Text & "' AND LineId = '" & dgObj.DataKeys(oGridItem.ItemIndex) & "' "
If WebCtrl.dsCount() > 0 Then
WebCtrl.strCommand = "INSERT INTO _temp1 SELECT * FROM APP_CAE1 WHERE AppId = '" & GetGridItem("AppId").Text & "' AND LineId = '" & dgObj.DataKeys(oGridItem.ItemIndex) & "' "
Else
WebCtrl.strCommand = "INSERT INTO _temp1 SELECT * FROM APP_CAE1 WHERE AppId = '" & GetGridItem("AppId").Text & "' AND LineId = '" & dgObj.DataKeys(oGridItem.ItemIndex) & "' "
End If
oCtr += 1
oAppId(oCtr) = GetGridItem("AppId").Text
oAppNo(oCtr) = GetGridItem("AppNo").Text
End If
Next
在我的代码中,我首先检查检查的行是什么,并将其包含在我的数据库中。但是,如果我有100条记录,循环将查看我网格中的所有行。我认为这是瓶颈。 :(