I suggest you use a real ORM (like LINQ to SQL) to interact with your own database rather than the Umbraco data layer, unless you really love writing your own TSQL statements :P.
If you really want to write TSQL you'll need to execute a scalar select query on your node ID, check if it returned something and then have an IF conditional to determine whether to do an Update or Insert.
How can I check if a value in a table already exist?
Hi Umbracians
I use this code to insert values
and this code to update
but that can't work, because it insert and update the values in the database at the same time :-).
How can I check if n.Id in mytable already exist?
I think of something like that
if (value... @NODEID = n.Id) {
UPDATE mytable SET...
}
else
INSERT INTO mytable...
Calvin
I suggest you use a real ORM (like LINQ to SQL) to interact with your own database rather than the Umbraco data layer, unless you really love writing your own TSQL statements :P.
If you really want to write TSQL you'll need to execute a scalar select query on your node ID, check if it returned something and then have an IF conditional to determine whether to do an Update or Insert.
is working on a reply...