I never have used SQL transactions, and in my case I know that I really will have to use them. One of the features of my App, is to convert an Excel file to a Database.
So I get the values from the Excel, build an array of strings with the arguments (to be sent to the SP) and some of the values I will insert directly in the main table, and others I will insert in secondary tables, and then I will get id's who will be in place of those values in the main table. What I am saying is that I have foreign keys, and it's why I do this.
So I think I am doing this perfectly but without transactions. But if anything goes wrong when I am inserting the values in the tables I will have to do the rollback.
So in the process I am using 5 stored procedures, one for each table. These SP's aren't exclusive to this process. They will be used in the App to insert records.
But I need help in where to use transaction. Should I do it in C# (app side) or in SQL Server (server side)?
For now I am using the SqlTransaction object from C# and it works in some way, because if I do the rollback he really cancels all the inserts, but the ID's that I have used in the transaction aren't available anymore. Only if I drop all the tables and create them again will those ID's be available again.
So I think that I am not using the transaction well and it's why I need help, to know how and where is better to use the transaction.