Click here to Skip to main content
15,911,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
4 Tables one-to-many relationship tables

Table A ..pk
Table B ..fk
Table C ..fk

updateTableA()
updateTableB()
updateTableC()
how to call 3 functions under at single function updateTable()

What I have tried:

cmd.CommandText = query;
cmd.Parameters.Add(new SqlParameter("@name", string.IsNullOrEmpty(listing.name)(object)DBNull.Value : listing.name));
cmd.Parameters.Add(new SqlParameter("@Year", listing.Year.HasValue ? listing.Year : 0));
Posted
Updated 29-Jan-21 3:40am

1 solution

With SQL Server? Your T-SQL statement could be something like:

SQL
BEGIN TRANSACTION
;
BEGIN TRY
;
UPDATE ...
;
UPDATE ...
;
UPDATE ...
;
COMMIT
;
END TRY
;
BEGIN CATCH
;
ROLLBACK
;
THROW
;
END CATCH


Then execute it with ExecuteNonQuery.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900