load recordset into textboxes
hi guys,
I am working on a proyect and i got stucked,
The thing is i have a form which contains a datagrid, and a group of txtboxes
I load information into the datagrid through a recorset called rsservices that uses a db table in informix ( i work with adodb connection and adodb recordsets)
and it works fine.
Then when you click in a record into the datagrid i want it to display the information of the row selected into the textboxes , there are like 5 textboxes each one shows a different info of the same row.
ex : row = Name, last name, address, gender, id etc
but i failed doing that
what I tried was, in the activated event of the form :
Code:
If rsservices.State = 1 Then
rsservices.Close()
End If
rsservices = Nothing
sql = "select * from services"
rsservices = cn.Execute(sql)
datagrid.DataSource = rsservices
'then here i match the database fields with the form textboxes
ex: txtname.text = rsservices("name").value
end sub
after i do all that and run the program the thing loads the first row into the textboxes but when i try to select another row from the datagrid it does nothing
somebody can help me please ??
Re: load recordset into textboxes
I dont know much about SQL in visual basic, but why not try a "For Each" statement
Example:
For Each VariableName As ObjectType In CollectionOfSomeSorts
'Code for what to do to VariableName. VariableName will = ObjectType. the 'As' arg is optional
Next
If you dont know what type of object it is, try this
For Each VariableName In CollectionInSomeSorts
'Code for what to do to VariableName. VariableName will be a String or Object (depending on the collection type)
Next