Index out of range. Must be non-negative in VB.NET -
I'm a newbie here, I'm getting an error regarding unable to resolve with myself (delete DataGridView part) So come here, ask for the guide and help me .... appreciate your help!
Load Data Incident `Public Sub-Load DDGV () New SqlDataAdapter as Stable = Sqlcmd as DM sqlq as Dim tbl. Connection with Sqladpt = conn end Select = sqlcmd Select = sqlcmd Fill (tbl) with DataGridView1.Rows.Clear end () I = 0 for tbl.Rows.Count- 1 with DataGridView1.Ro Add (tbl.Rows (i) ("ChatConttentID"), tbl.Rows (i) ("title"), tbl.rows (i) ("chat content"), TBL.ro ("chat date time" "), TBL. ROS (I) (" User Name ")) and the next conn with the signal. Close () End Sabba Delete Part Error Error `conn.State = ConnectionState.Closed then conn.Open () end if I = 0 DataGridView1.Rows.Count for - 1 Dim Deletemore Integer = DataGride View 1. Selected (I). Game (0). Value and lieutenant; ------ {error in line} String = as the squared square (remove from "playful where chat content id =" & "delete" and "sqlcmd" as sqlcmd with new sqlcommand .CommandText = Sqlq. Connection = conn .ExecuteNonQuery () with the next load DGV () `
So I am assuming that your application is a windows form application and you are using control ... sorry if this assumption is false.
Your error The reason you use to write the form is due to the reason:
for I for DataGridView1.Rows.Count - 1Dimatom integer = DataGridView1.SelectedRows (i) (0) .Well and Lieutenant; ------ {Line Happened Error} You are looping through all the rows in the DataGrid view and then indexing that index Trying to get it from the collection.
Your loop is making an impression, I think, this is wrong It takes a lot of time to believe that all the rows are selected in the DataGrid view (because it is the only time when the items in the # DataGridView and #Get DataGridView.SelectedRows will be equal to the item and the loop will work. )
You will probably have a looping through selected rows, using something like, better:
dim numselectedRows = DataGridView1. Have selected. I for num = 0 (numselectedRows - 1) Dim Deletemore as integer = DataGridView1.SelectedRows (i) .Cell (0). There are some warnings on the property around selection mode for PS control (see "Remarks" section in the link) I think you are following those warnings.
`Public Sub-Load DDGV () New SqlDataAdapter as Stable = Sqlcmd as DM sqlq as Dim tbl. Connection with Sqladpt = conn end Select = sqlcmd Select = sqlcmd Fill (tbl) with DataGridView1.Rows.Clear end () I = 0 for tbl.Rows.Count- 1 with DataGridView1.Ro Add (tbl.Rows (i) ("ChatConttentID"), tbl.Rows (i) ("title"), tbl.rows (i) ("chat content"), TBL.ro ("chat date time" "), TBL. ROS (I) (" User Name ")) and the next conn with the signal. Close () End Sabba Delete Part Error Error `conn.State = ConnectionState.Closed then conn.Open () end if I = 0 DataGridView1.Rows.Count for - 1 Dim Deletemore Integer = DataGride View 1. Selected (I). Game (0). Value and lieutenant; ------ {error in line} String = as the squared square (remove from "playful where chat content id =" & "delete" and "sqlcmd" as sqlcmd with new sqlcommand .CommandText = Sqlq. Connection = conn .ExecuteNonQuery () with the next load DGV () `
So I am assuming that your application is a windows form application and you are using control ... sorry if this assumption is false.
Your error The reason you use to write the form is due to the reason:
for I for DataGridView1.Rows.Count - 1Dimatom integer = DataGridView1.SelectedRows (i) (0) .Well and Lieutenant; ------ {Line Happened Error} You are looping through all the rows in the DataGrid view and then indexing that index Trying to get it from the collection.
Your loop is making an impression, I think, this is wrong It takes a lot of time to believe that all the rows are selected in the DataGrid view (because it is the only time when the items in the # DataGridView and #Get DataGridView.SelectedRows will be equal to the item and the loop will work. )
You will probably have a looping through selected rows, using something like, better:
dim numselectedRows = DataGridView1. Have selected. I for num = 0 (numselectedRows - 1) Dim Deletemore as integer = DataGridView1.SelectedRows (i) .Cell (0). There are some warnings on the property around selection mode for PS control (see "Remarks" section in the link) I think you are following those warnings.
Comments
Post a Comment