In a robust enterprise application, the processing of the transaction is extremely important. If you are preparing to develop an enterprise application, you better understand more.
Some content about this; of course, I hope that my article will help you. What places in the actual solution need to use a transaction?
For the full type of each enterprise entity data in the database, we usually define a series of primary keys and some rules when designing the database;
The setting is the most important, in theory, by these constraints can guarantee a complete type of a single data entity, it seems that the business is not needed, but it is true that
The program is lack of robustness. To this end, we must be an insurance as a constraint defined in the database, and for the reliability of the entire solution, our superiority
Transactions must be used again.
If your program will encounter the following situations, you should take care of your business:
I. (Typical) When writing a customized data (main reason), you should use transactions in business logic or data access.
Method 1: Using OLEDBTRANSACTION
Method 2: Using COM transaction (afraid of trouble method 1)
II. When writing a foreign key constraint, you should do this.
Begintran (); / / lock
2. Judging whether the foreign key association data exists
3. Decide whether to write data according to the second step
4. Commit (); or rollback ();
......
Here I don't want to use more examples, and then say something yourself on the second case:
Some people think that this approach seems to be excessive, right, looks; but your program is very strong, readable and can be great
Reduce database end bottlenecks; (untransmitted)