I have a basic program that access a local Access database, reads data from it into a datagrid, and then allows me to manipulate it by using textboxes. I can add, delete, and search for records. I want to remove the textboxes from the equation completely. Is there any way I can access the data in the datagrid through code so I can use it in SQL statements?

i.e. DataGrid.SelectedRow.Column(3).Value

initial condition

Dim i As Integer
i = dgUser.CurrentRowIndex()

i.e : (this following code will select user where id user = value of first column from selected datagrid). Of course in datagrid click event :

Private Sub dgPendidikan_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgPendidikan.Click
...
cmdUser.CommandText = "SELECT * FROM Users where IdUser ='" & Trim(dgUser.Item(i, 0)) & "'"
....
end sub
Comments
Great

Thank you so much! I am teaching myself databases, and was stuck on this for days. I thought I tried everything, but I guess not. Thanks!

This question has already been answered. Start a new discussion instead.