Hello,
I have 4 tables having Customer, Customer_personal_info, Customer_Financial_info, Customer_Other_info
In this Customer table had a primary key CustomerID , related with every other table with fkey.
I want to insert data into four tables using one form having TABs .
I created class and storedProcedures to insert row for each table.
How to execute all four classes using beginTrans-commitTrans-Rollback-EndTrans.
Thanking you,
Hi
I am not sure if you have created one stored procedure or four stored procedures (your post mentions "stored procedures")..
If you want to go the stored procedure way, It is ideal to create one stored procedure on which you can use a SQL level BEGIN TRAN and ROLLBACK. These are keywords written inside the SQL stored procedure.
Another way is to execute the queries or stored procedures usingSQLCommand's ExecuteNonQuery method, but before execution create aSQLTransaction object and associate that with the SQLconnection. If the transaction (Insert statements in SQL or SP) works fine, thencommit the transaction.
HTH
VJ
No comments:
Post a Comment