oledb and FindBy[ColumnName] for DataGrids

  • Thread starter Thread starter David R. Longnecker
  • Start date Start date
D

David R. Longnecker

While attempting to migrate from my old "loop through all records" mindset with ADO 3.0 and into the ADO.NET arena, I've come across an issue using DataGrids with the OLEDB and Oracle data connection objects.

I began using the C# MSDN article (http://msdn.microsoft.com/library/d...ughUsingDataGridWebControlToReadWriteData.asp) on DataGrid web controls and was very successful until...

-- Code --
dsCategories.CategoriesRow r;
r = dsCategories1.Categories.FindByCategoryID(int.Parse(key));
-- /Code --

It appears that the second line, the "FindBy[ColumnName]" doesn't exist for any connection object except Sql (at least that was the only one that it appeared on). My applications will require a mix of SQL, Oracle, and other OLEDB compliant data sources--is there a better way than the MSDN article to determine the edited row of a DataGrid for Updating? I've Googled many responses; however, most everything I can find is dramatically different than the MSDN architecture; focusing on instantiating the objects dynamically in the code rather than through the GUI--and I'm not quiet to the comfort level to translate the code.

Thanks in advance!

-David
 
David,

I'm not exactly sure what you are trying to do. However, it appears that you are trying to get the changes on a data set (or the current row).

What you could do is take the data source (the DataTable), and call the GetChanges method on it. This will return a DataTable populated with rows that represent the rows that have been changed.

You could also get the currently edited row by going through the BindingContext. If you pass the data source that you populated the data grid with (it's important that the data source and data member match EXACTLY in this case), it will return to you a CurrencyManager. From there, you can call the Current property, and cast that to a DataRowView, which will represent the current row being edited.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
While attempting to migrate from my old "loop through all records" mindset with ADO 3.0 and into the ADO.NET arena, I've come across an issue using DataGrids with the OLEDB and Oracle data connection objects.

I began using the C# MSDN article (http://msdn.microsoft.com/library/d...ughUsingDataGridWebControlToReadWriteData.asp) on DataGrid web controls and was very successful until...

-- Code --
dsCategories.CategoriesRow r;
r = dsCategories1.Categories.FindByCategoryID(int.Parse(key));
-- /Code --

It appears that the second line, the "FindBy[ColumnName]" doesn't exist for any connection object except Sql (at least that was the only one that it appeared on). My applications will require a mix of SQL, Oracle, and other OLEDB compliant data sources--is there a better way than the MSDN article to determine the edited row of a DataGrid for Updating? I've Googled many responses; however, most everything I can find is dramatically different than the MSDN architecture; focusing on instantiating the objects dynamically in the code rather than through the GUI--and I'm not quiet to the comfort level to translate the code.

Thanks in advance!

-David
 
Hi David,

FindByCategoryID was generated by the DataSet designer. When a column is
the Primary Key in a table, a FindByColumnName method will be automatically
generated. It seems in this article, a typed DataSet is used. You have to
create the typed DataSet according to you needs.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top