UpdateCommand and InsertCommand for the same DataAdapter?

R

Rico

Hello,

Can you create both an UpdateCommand and an InsertCommand for the same DA?
If so, what's the best way to do this and how do you call it? What I'm
trying to do is add records if they don't exist and update them if they do.

Thanks!
 
W

W.G. Ryan - MVP

Yes, you can (and should) specify both if you plan on having your UI update
and do inserts as well. Remember that the adapter uses Rowstate to
determine which command it will fire for the given row, so which command you
modfiy will depend partially on your application.

But you can do an Command that checks for the existence of a row and then
inserts it. However it's important to take note of how that row is going to
get into the DataTable in the first place.

Are you familiar with Rowstate? If not, let me know but if you are, then
just remember that Added maps to the Insert command, Modified maps to the
Update command.
"Rico" <r c o l l e n s @ h e m m i n g w a y . c o mREMOVE THIS PART IN
CAPS> wrote in message news:tzWTf.167564$H%4.31117@pd7tw2no...
 
R

Rico

Hi WG.

Thanks. I am familiar with Rowstate, but just new enough not to know all
the angles. I will likely be able to figure the rest out. One question
though, can I create an insert statement using a wildcard to represent all
fields? i.e., can I create the insert command without having to specify
every field in the underlying table?

Thanks!
 
W

W.G. Ryan - MVP

Hi Rico:

You're going to need to specify at a minimum the values that you want
updated. Is this what you were asking?
"Rico" <r c o l l e n s @ h e m m i n g w a y . c o mREMOVE THIS PART IN
CAPS> wrote in message news:kO_Tf.170870$B94.121448@pd7tw3no...
 
R

Rico

Yup, that pretty much answers my question. I was hoping that there would be
an easy way of automapping all fields, similar to the following;

"INSERT INTO Operation VALUES (*)"

(can you tell I come from a RAD background?)

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top