Databings & Insert New Record

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

    #1

    Databings & Insert New Record

    Using a Windows Application Form I have about 20-30 fields displayed on a
    Form that are bound to a dataset.

    Rather than create a large SQL command/Stored Procedure to insert each of
    these fields, can I not use the CommandBuilder and the Databinding?

    I cannot work out how to force the dataset's DataRowState to "Added"

    Am I missing something really simple or is this something that cannot be done?

    Any help greatly appreciated.
  • Cor Ligthert

    #2
    Re: Databings & Insert New Record

    Supa,
    [color=blue]
    > Am I missing something really simple or is this something that cannot be[/color]
    done?

    When I understand your message well, probably yes.

    BindingContext( ds.Tables(0)).E ndCurrentEdit()

    I hope this helps?

    Cor


    Comment

    • Cor Ligthert

      #3
      Re: Databings & Insert New Record

      Supa,

      Did you try what I showed in your showbutton procedure?


      Cor


      Comment

      • Cor Ligthert

        #4
        Re: Databings & Insert New Record

        savebutton[color=blue]
        >
        > Did you try what I showed in your showbutton procedure?
        >[/color]


        Comment

        • Supa Hoopsa

          #5
          Re: Databings & Insert New Record

          Yes I tried that, but the dataset.haschan ges(DataRowStat e) still = modified.

          How do I get it to ADD/INSERT a new record?

          "Cor Ligthert" wrote:
          [color=blue]
          > savebutton[color=green]
          > >
          > > Did you try what I showed in your showbutton procedure?
          > >[/color]
          >
          >
          >[/color]

          Comment

          • Cor Ligthert

            #6
            Re: Databings & Insert New Record

            Hi Suspa,

            The dataset haschanges is for all tables and all rows in a dataset. I wished
            there was a datatable.hasch anges because now you are forced to use seperated
            datasets when you want to update some tables in advance.

            When you want individual rows checked, you have to check those using the
            row, what is possible as well.

            http://msdn.microsoft.com/library/de...statetopic.asp

            I hope this helps?

            Cor
            [color=blue]
            > Yes I tried that, but the dataset.haschan ges(DataRowStat e) still =[/color]
            modified.[color=blue]
            >
            > How do I get it to ADD/INSERT a new record?
            >
            > "Cor Ligthert" wrote:
            >[color=green]
            > > savebutton[color=darkred]
            > > >
            > > > Did you try what I showed in your showbutton procedure?
            > > >[/color]
            > >
            > >
            > >[/color][/color]


            Comment

            • Mash

              #7
              RE: Databings & Insert New Record

              Do you have an answer to this issue yet?

              I have the same problem. I add a row to a DataTable (at which point the
              RowState is "Added"), but I let the user change values before I insert to the
              DB. The RowState has changed to "Modified" so my insert doesn't happen.

              Tried creating a new DataTable to use for inserts and using the Copy() and
              ImportRow() methods but they all take the "Modified" row state with them.

              "Supa Hoopsa" wrote:
              [color=blue]
              > Using a Windows Application Form I have about 20-30 fields displayed on a
              > Form that are bound to a dataset.
              >
              > Rather than create a large SQL command/Stored Procedure to insert each of
              > these fields, can I not use the CommandBuilder and the Databinding?
              >
              > I cannot work out how to force the dataset's DataRowState to "Added"
              >
              > Am I missing something really simple or is this something that cannot be done?
              >
              > Any help greatly appreciated.[/color]

              Comment

              • Neil Allen

                #8
                Re: Databings & Insert New Record

                On Thu, 30 Sep 2004 20:19:01 -0700, "Mash"
                <Mash@discussio ns.microsoft.co m> wrote:
                [color=blue]
                >Do you have an answer to this issue yet?
                >
                >I have the same problem. I add a row to a DataTable (at which point the
                >RowState is "Added"), but I let the user change values before I insert to the
                >DB. The RowState has changed to "Modified" so my insert doesn't happen.
                >
                >Tried creating a new DataTable to use for inserts and using the Copy() and
                >ImportRow() methods but they all take the "Modified" row state with them.
                >
                >"Supa Hoopsa" wrote:
                >[color=green]
                >> Using a Windows Application Form I have about 20-30 fields displayed on a
                >> Form that are bound to a dataset.
                >>
                >> Rather than create a large SQL command/Stored Procedure to insert each of
                >> these fields, can I not use the CommandBuilder and the Databinding?
                >>
                >> I cannot work out how to force the dataset's DataRowState to "Added"
                >>
                >> Am I missing something really simple or is this something that cannot be done?
                >>
                >> Any help greatly appreciated.[/color][/color]

                Dear Mash,

                In our limited experience we've found that the RowState value of a
                newly added row is "Added" until "AcceptChanges( )" is called - even
                if the user changes the data in the newly added row.

                Are you sure you haven't called "AcceptChanges( )" somewhere in your
                program?

                I'm interested in the problem, so if you can post the fewest possible
                lines of code to illustrate the problem then I'd be happy to have a
                closer look.


                Regards

                Neil Allen

                Comment

                • Mash

                  #9
                  Re: Databings &amp; Insert New Record

                  Hi Neil,

                  Yep - you got me. On the 23rd look through the code there was indeed an
                  AcceptChanges() call out there screwing me up. Working great now of course!

                  Thanks for replying...

                  "Neil Allen" wrote:
                  [color=blue]
                  > On Thu, 30 Sep 2004 20:19:01 -0700, "Mash"
                  > <Mash@discussio ns.microsoft.co m> wrote:
                  >[color=green]
                  > >Do you have an answer to this issue yet?
                  > >
                  > >I have the same problem. I add a row to a DataTable (at which point the
                  > >RowState is "Added"), but I let the user change values before I insert to the
                  > >DB. The RowState has changed to "Modified" so my insert doesn't happen.
                  > >
                  > >Tried creating a new DataTable to use for inserts and using the Copy() and
                  > >ImportRow() methods but they all take the "Modified" row state with them.
                  > >
                  > >"Supa Hoopsa" wrote:
                  > >[color=darkred]
                  > >> Using a Windows Application Form I have about 20-30 fields displayed on a
                  > >> Form that are bound to a dataset.
                  > >>
                  > >> Rather than create a large SQL command/Stored Procedure to insert each of
                  > >> these fields, can I not use the CommandBuilder and the Databinding?
                  > >>
                  > >> I cannot work out how to force the dataset's DataRowState to "Added"
                  > >>
                  > >> Am I missing something really simple or is this something that cannot be done?
                  > >>
                  > >> Any help greatly appreciated.[/color][/color]
                  >
                  > Dear Mash,
                  >
                  > In our limited experience we've found that the RowState value of a
                  > newly added row is "Added" until "AcceptChanges( )" is called - even
                  > if the user changes the data in the newly added row.
                  >
                  > Are you sure you haven't called "AcceptChanges( )" somewhere in your
                  > program?
                  >
                  > I'm interested in the problem, so if you can post the fewest possible
                  > lines of code to illustrate the problem then I'd be happy to have a
                  > closer look.
                  >
                  >
                  > Regards
                  >
                  > Neil Allen
                  >
                  >[/color]

                  Comment

                  • Neil Allen

                    #10
                    Re: Databings &amp; Insert New Record

                    On Fri, 1 Oct 2004 15:17:08 -0700, "Mash"
                    <Mash@discussio ns.microsoft.co m> wrote:
                    [color=blue]
                    >Hi Neil,
                    >
                    >Yep - you got me. On the 23rd look through the code there was indeed an
                    >AcceptChanges( ) call out there screwing me up. Working great now of course!
                    >
                    >Thanks for replying...
                    >
                    >"Neil Allen" wrote:
                    >[color=green]
                    >> On Thu, 30 Sep 2004 20:19:01 -0700, "Mash"
                    >> <Mash@discussio ns.microsoft.co m> wrote:
                    >>[color=darkred]
                    >> >Do you have an answer to this issue yet?
                    >> >
                    >> >I have the same problem. I add a row to a DataTable (at which point the
                    >> >RowState is "Added"), but I let the user change values before I insert to the
                    >> >DB. The RowState has changed to "Modified" so my insert doesn't happen.
                    >> >
                    >> >Tried creating a new DataTable to use for inserts and using the Copy() and
                    >> >ImportRow() methods but they all take the "Modified" row state with them.
                    >> >[/color][/color][/color]

                    <snip>

                    Dear Mash

                    Jolly good!

                    Regards

                    Neil Allen



                    Comment

                    Working...