hi am trying to populate a datagrid with data from my database using a search function but i get this error
"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
this my code
"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
this my code
conn.Open()
searchresults = False
Dim sql, ids As String
ids = "%" + id + "%"
sql = "SELECT * FROM products WHERE productid like '" & ids & "'"
cmd = New MySqlCommand(sql, conn)
Dim rd As MySqlDataReader
rd = cmd.ExecuteReader
Dim i As Integer
While rd.Read
DataGridView1.Rows(i).Cells(1).Value = rd.Item("productname")
DataGridView1.Rows(i).Cells(0).Value = rd.Item("productid")
DataGridView1.Rows(i).Cells(2).Value = rd.Item("sellingprice")
i = i + 1
End While
rd.Close()
conn.Close()
searchresults = True