ADO2 "Rows" question

  • Thread starter Thread starter phonl
  • Start date Start date
P

phonl

In ADO2, how would I find the position of "x" in:

myDataSet.Tables("myTable").Rows(x).Item("myField") = "NewValue"

I want to manipulate some data in the current row in my dataset, but it
seems that I have to know the index of the row that my dataset is at. How
do I find the index of the current row?
 
Hi phonl,

Actually, you needn't get the position of it. If you already have the
BindingSource object, the BindingSource.Current property returns the
current DataRow object. Manipulate on that object to set the new value. If
you really need to get the position, BindingSource.Position property will
do the trick.

Hope that helps.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Thank you Kevin; that works great. I used the DataRowView object of
BindingSource.Current.

Another question on this topic; If I decided not to use the BindingSource
and just go with a TableAdaper and DataSet, is there a way to know the
position of x?

myDataSet.Tables("myTable").Rows(x).Item("myField") = "NewValue"
 
Thank you Kevin; that works great. I used the DataRowView object of
BindingSource.Current.

Another question on this topic; If I decided not to use the BindingSource
and just go with a DataAdaper and DataSet, is there a way to know the
position of x?

myDataSet.Tables("myTable").Rows(x).Item("myField") = "NewValue"
 
Hi phonl,

Yes, you can still get that current row with CurrencyManager. If you are
binding the DataSet to a DataGrid like:

dataGrid1.DataSource = DataSet1.Tables[0];

You can get the CurrencyManager like

CurrencyManager cm =
(CurrencyManager)dataGrid1.BindingContext[DataSet1.Tables[0]);

cm.Current is that DataRowView object and cm.Position is the position of
currencly selected row. Actually, BindingSource is getting that information
from the CurrencyManager. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
You're welcome.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top