ADO2 "Rows" question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • phonl

    #1

    ADO2 "Rows" question

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

    myDataSet.Table s("myTable").Ro ws(x).Item("myF ield") = "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?



  • Kevin Yu [MSFT]

    #2
    RE: ADO2 "Rows&quot ; question

    Hi phonl,

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

    Hope that helps.

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

    Comment

    • phonl

      #3
      Re: ADO2 "Rows&quot ; question

      Thank you Kevin; that works great. I used the DataRowView object of
      BindingSource.C urrent.

      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.Table s("myTable").Ro ws(x).Item("myF ield") = "NewValue"




      "Kevin Yu [MSFT]" <v-kevy@online.mic rosoft.com> wrote in message
      news:8KYqAzITGH A.4824@TK2MSFTN GXA03.phx.gbl.. .[color=blue]
      > Hi phonl,
      >
      > Actually, you needn't get the position of it. If you already have the
      > BindingSource object, the BindingSource.C urrent property returns the
      > current DataRow object. Manipulate on that object to set the new value. If
      > you really need to get the position, BindingSource.P osition property will
      > do the trick.
      >
      > Hope that helps.
      >
      > Kevin Yu
      > =======
      > "This posting is provided "AS IS" with no warranties, and confers no
      > rights."
      >[/color]


      Comment

      • phonl

        #4
        Re: ADO2 &quot;Rows&quot ; question

        Thank you Kevin; that works great. I used the DataRowView object of
        BindingSource.C urrent.

        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.Table s("myTable").Ro ws(x).Item("myF ield") = "NewValue"


        "Kevin Yu [MSFT]" <v-kevy@online.mic rosoft.com> wrote in message
        news:8KYqAzITGH A.4824@TK2MSFTN GXA03.phx.gbl.. .[color=blue]
        > Hi phonl,
        >
        > Actually, you needn't get the position of it. If you already have the
        > BindingSource object, the BindingSource.C urrent property returns the
        > current DataRow object. Manipulate on that object to set the new value. If
        > you really need to get the position, BindingSource.P osition property will
        > do the trick.
        >
        > Hope that helps.
        >
        > Kevin Yu
        > =======
        > "This posting is provided "AS IS" with no warranties, and confers no
        > rights."
        >[/color]


        Comment

        • Kevin Yu [MSFT]

          #5
          Re: ADO2 &quot;Rows&quot ; question

          Hi phonl,

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

          dataGrid1.DataS ource = DataSet1.Tables[0];

          You can get the CurrencyManager like

          CurrencyManager cm =
          (CurrencyManage r)dataGrid1.Bin dingContext[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."

          Comment

          • phonl

            #6
            Re: ADO2 &quot;Rows&quot ; question

            Thanks again Kevin. I was able to make it work from your example.


            "Kevin Yu [MSFT]" <v-kevy@online.mic rosoft.com> wrote in message
            news:iEzkw2XTGH A.5524@TK2MSFTN GXA03.phx.gbl.. .[color=blue]
            > Hi phonl,
            >
            > Yes, you can still get that current row with CurrencyManager . If you are
            > binding the DataSet to a DataGrid like:
            >
            > dataGrid1.DataS ource = DataSet1.Tables[0];
            >
            > You can get the CurrencyManager like
            >
            > CurrencyManager cm =
            > (CurrencyManage r)dataGrid1.Bin dingContext[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."
            >[/color]


            Comment

            • Kevin Yu [MSFT]

              #7
              Re: ADO2 &quot;Rows&quot ; question

              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."

              Comment

              Working...