Results 1 to 7 of 7

Thread: [2005] AbsolutePosition

  1. #1

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    59

    [2005] AbsolutePosition

    Hi All,
    Is there any equivalent of AbsolutePosition from RecordSet into DataSet?

  2. #2

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] AbsolutePosition

    How about you explain what you're trying to accomplish and then we can tell you how to accomplish it best in VB.NET? I have no idea what AbsolutePosition is but I bet I could tell you how to do what you want to do, if I knew what that was. Take the time and make the effort to provide a full and clear description of your issue from the start, instead of typing the shortest possible sentence you can, is going to give you a far better chance of getting the answer you want. That's good for you, isn't it?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: [2005] AbsolutePosition

    Quote Originally Posted by jmcilhinney
    How about you explain what you're trying to accomplish and then we can tell you how to accomplish it best in VB.NET? I have no idea what AbsolutePosition is but I bet I could tell you how to do what you want to do, if I knew what that was. Take the time and make the effort to provide a full and clear description of your issue from the start, instead of typing the shortest possible sentence you can, is going to give you a far better chance of getting the answer you want. That's good for you, isn't it?
    AbsolutePosition was used in VB6 which indicates the ordinal position of a Recordset object's current record.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] AbsolutePosition

    Quote Originally Posted by Deepak Sakpal
    AbsolutePosition was used in VB6 which indicates the ordinal position of a Recordset object's current record.
    Then the DataSet itself has no equivalent. There's no such thing as a selected row in a DataTable. Such a selection only makes sense in terms of bound data, in which case you'd use the Current (item) or Position (index) property of a BindingSource. The BindingSource hides the complexity of the CurrencyManager, amongst other things, so it is generally easier to use. Like I said, if a full and clear description is provided...
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    59

    Re: [2005] AbsolutePosition

    Quote Originally Posted by jmcilhinney
    Then the DataSet itself has no equivalent. There's no such thing as a selected row in a DataTable. Such a selection only makes sense in terms of bound data, in which case you'd use the Current (item) or Position (index) property of a BindingSource. The BindingSource hides the complexity of the CurrencyManager, amongst other things, so it is generally easier to use. Like I said, if a full and clear description is provided...
    I just want to easily recall the position of the data in a dataset created by a certain SQL command. In this way, whereever my code goes in same class i could just simply recall it. please see my vb6 explaination:

    vb6 code---

    Code:
    dim posN as integer
    private sub btn1_click (to initialize the recordset)
       SQL and recordset manipulation (adodb) here...
    end sub
    if i hv a navigator buttons like First, Previous, Next or Last then i would code this as:

    Code:
    private sub btnFirst
       some other codes here...
    end sub
    
    private sub btnPrev...
    private sub btnNext...
    private sub btnLast...
    after several several uses of first, next, prev or last buttons, it is only the recorset know the location of the cursor inside the recordset. In this case we need to put Label control as a UI guide which shows the value like "3 OF 5". If you are in edit or add mode, you can put now the posN as your virtual cursor. pls see code below:

    Code:
    private sub btnAdd_click (same as btnEdit)
        posN=mid(lbDisplay.text.....) 'to get the current value which is "3" in the "3 OF 5" display
        some code here....
    end sub
    after this, if the user press the Cancel button, we can just code it as:

    Code:
    private sub btnCancel
        some code here....
        adodb.recordset.abosuleposition = posN
        txtSample.DataField=adodb.RecordSet.Fields(fldName).Name 
    end sub
    Well, that is how could I explain for the abosuluteposition that i suppose to use in datasets. what i am always doing is i have to Dim a variable integer and then assigned a value in it everytime there are updates or changes in the datasets which sometimes the code will be repeating and found it lazy to type unlike the vb6 absoluteposition feature which is 1 line and few charachters to type in.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] AbsolutePosition

    As I have already pointed out, there is no equivalent. A DataSet is just a collection of DataTables which is each a collection of DataRows. It just sits there containing data. A DataSet or a DataTable has no concept of a current row. You could be accessing that data from multiple places and each of those places could be accessing a different row, so which one would be the current row?

    A current row only makes sense from the point of view of an object accessing the data. If you're displaying the data in the UI then you should do so via a BindingSource. Whichever row is currently selected in the UI will be accessed via the Current property of the BindingSource and its index will be accessed via the Position property.

    Note that the Current property is read-only but the Position property is not, so you can select a specific row by setting the Position property. Note also that the BindingSource has MoveFirst, MovePrevious, MoveNext and MoveLast methods. In that sense it is the BindingSource that provides behaviour analogous to the Recordset, not the DataSet.

    It's also worth noting that these members of the BindingSource are essentially pass-throughs for the underlying CurrencyManager. It's just that a BindingSource is easier to work with, plus adds other functionality too, like sorting and filtering.

    So, in short, you should assign your DataTable to the DataSource property of a BindingSource. You can then navigate the data in the BindingSource much as you did with the Recordset. You can then bind the BindingSource to your UI elements if you want, which is what it's usually used for.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width