Index was out of range. Must be non-negative and less than the size of the collection....

  • Thread starter Thread starter s.pac
  • Start date Start date
S

s.pac

Guest
Please help ive got this error

here is my code

matching records from textbox to datagridview
Private Sub tbxDnumber_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbxDnumber.TextChanged
Dim i As Integer
Dim j As Integer
For i = 0 To DataGridView1.Rows.Count - 1
For j = 0 To DataGridView1.Rows.Count - 1
If tbxDnumber.Text = Me.DataGridView1.Rows(i).Cells(j).Value Then

tbxstatus.Text = "Returned"

mysqlconn = New MySqlConnection
mysqlconn.ConnectionString =
"server=localhost;userid=root;password=admin;database=withdrawaldb"
Dim rdr As MySqlDataReader
Try
mysqlconn.Open()
Dim qry As String
qry = "insert into withdrawaldb.returnedtbl (DIE_NUMBER,MACHINE_NUMBER,BADGE_NUMBER,DATE,STATUS) values (" & tbxDnumber.Text & "," & tbxMnumber.Text & "," & tbxbadge.Text & "," & DateTimePicker1.Value & "," & tbxstatus.Text & ")"
cmd = New MySqlCommand(qry, mysqlconn)
rdr = cmd.ExecuteReader
delete_withdraw()

tbxMnumber.Clear()
tbxbadge.Clear()
tbxstatus.Clear()
tbxMnumber.Select()

mysqlconn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
mysqlconn.Dispose()
End Try



load_returnedtbl()
DataGridView2.Sort(DataGridView2.Columns(1), ListSortDirection.Ascending)
tbxDnumber.Clear()
End If
Exit For
Next
Next
End Sub
589677


Continue reading...
 
Back
Top