shimakh
کاربر تازه وارد
- تاریخ عضویت
- 11 دسامبر 2006
- نوشتهها
- 115
- لایکها
- 0
سلام
دوستان عزیز کسی می دونه این پیغام خطا رو برای چی به من می ده؟؟؟
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index دوستان عزیز کسی می دونه این پیغام خطا رو برای چی به من می ده؟؟؟
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Source Error:
Line 32: Dim CmdDelete As OleDbCommand
Line 33: Dim StrNewsId As String
Line 34: StrNewsId=dlstNews.DataKeys(e.Item.ItemIndex)
Line 35: ConNews=New OleDbConnection("PROVIDER=MICROSOFT.jet.OLEDB.4.0;DATA source=C:\inetpub\wwwroot\WebApplication2\web-data.mdb")
Line 36: StrDelete="Delete From News Where id=@id"
کد:
Sub dlstNews_updateCommand(s As Object, e As DataListCommandEventArgs )
Dim ConNews As OleDbConnection
Dim StrUpdate As String
Dim CmdUpdate As OleDbCommand
Dim StrNewsId As String
Dim txttotal As TextBox
Dim txtdistribute As TextBox
'If e.Item.ItemIndex > -1 Then
StrNewsId=dlstNews.DataKeys(e.Item.ItemIndex)
'End If
txttotal=e.Item.FindControl("txttotal")
txtdistribute=e.Item.FindControl("txtdistribute")
ConNews=New OleDbConnection("PROVIDER=MICROSOFT.jet.OLEDB.4.0;DATA source=C:\inetpub\wwwroot\WebApplication2\web-data.mdb")
StrUpdate="Update News Set total=@total, distribute=@distribute Where id=@id"
CmdUpdate=New OleDbCommand(StrUpdate, ConNews)
CmdUpdate.Parameters.Add("@Id", StrNewsId)
CmdUpdate.Parameters.Add("@total",txttotal.Text)
CmdUpdate.Parameters.Add("@distribute",txtdistribute.Text)
ConNews.Open()
CmdUpdate.ExecuteNonQuery()
ConNews.Close()
dlstNews.EditItemIndex=-1
BindDataList
End Sub