DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   Accessing data in a datagrid... (http://www.daniweb.com/forums/thread127395.html)

phantom715 Jun 2nd, 2008 8:14 pm
Accessing data in a datagrid...
 
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

Jx_Man Jun 2nd, 2008 11:04 pm
Re: Accessing data in a datagrid...
 
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

phantom715 Jun 2nd, 2008 11:29 pm
Re: Accessing data in a datagrid...
 
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!

Jx_Man Jun 2nd, 2008 11:46 pm
Re: Accessing data in a datagrid...
 
you're Welcome :)


All times are GMT -4. The time now is 9:48 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC