Preferred way to do "update row, or insert if it doesn't exist" using TableAdapters in dataset desig

H

H5N1

hi there

the topic says it all.

I have a outer join select statement in tableadapter that populates
GridView, I want to make it updatetable, so I need to provide an update
command for table adapter.
the problem is that not all rows in gridview exist in database (since
it's an outer join) so I want to UPDATE statement to insert the row if
it doesn't exist.

What's the best practice?

thanks
 
G

Guest

The Sql "Pattern" for this would be (pseudocode)

IF NOT EXISTS( SELECT PrimaryKey from table where primaryKey=@primarykey)
BEGIN
INSERT INTO TABLE ---etf
END
ELSE
BEGIN
UPDATE TABLE SET .... etc
END
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top