Databings & Insert New Record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
Supa,
Am I missing something really simple or is this something that cannot be
done?

When I understand your message well, probably yes.

BindingContext(ds.Tables(0)).EndCurrentEdit()

I hope this helps?

Cor
 
Yes I tried that, but the dataset.haschanges(DataRowState) still = modified.

How do I get it to ADD/INSERT a 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.
 
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.

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

<snip>

Dear Mash

Jolly good!

Regards

Neil Allen
 
Back
Top