How to Spell-Out C# Cursor Position in DataTable?

Posted on 2012-08-22
Last Modified: 2012-08-23
I am writing a database program in C# using Microsoft Access. I have a lot of code written.

I am need of knowing exactly how to spell out an instruction that returns the integer position of the last row fetched with the Find() operation.

Can anyone quickly spell this out for me?
Question by:Leonard Gojer
    LVL 96

    Expert Comment

    by:Bob Learned
    That is not possible with the current state of the DataTable/DataRow.  You would have to do some custom work, to create an extended DataRow class to store the row index.  I did it in the past, although I don't have access to that code anymore.

    Author Comment

    by:Leonard Gojer
    Question #1: "What is an extended DataRow?"

    Question #2: "How does the extended DataRow store the row index?"

    Question #3: "Can you direct me to web literature about this topic so that I can get
    some ideas of how I write the coding myself?"
    LVL 96

    Accepted Solution

    An extended DataRow class would inherit from DataRow, and add an additional RowIndex property, but unfortunately the DataTable and DataRow classes are not designed very well to extend.

    Here is an example:

    Not sure how to inherit DataRow correctly...

    public class MyObj
    	public class DataTable : Data.DataTable
    		protected override DataRow NewRowFromBuilder(DataRowBuilder builder)
    			return new MyObj.DataRow(builder);
    		public MyObj.DataRow this[int index] {
    			get { return (MyObj.DataRow)this.Rows(index); }
    		public void TrySomethingCool()
    	public class DataRow : Data.DataRow
    		private MyObj.DataTable _datatable;
    		internal DataRow(DataRowBuilder rb) : base(rb)
    			this._datatable = (MyObj.DataTable)this.Table;
    		public void DoMyThing()

    Open in new window


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now