1、事务处理问题?能否设置为显式commit?
对事务边界的控制取决于为应用程序选择的事务模型:手动或自动。在手动事务中,用开始和结束事务的显式指令控制事务边界。从一个事务边界内可以开始第二个被称为嵌套事 务的事务。直到所有从属事务提交,其父事务才提交。
ADO.NET supports transactions through the Transaction object, which is created against
an open connection. Commands that are executed against the connection while the
transaction is pending must be enrolled in the transaction by assigning a reference to the
Transaction object to their Transaction property. Commands cannot be executed against
the Connection outside the transaction while it is pending.
If the transaction is committed, all of the commands that form a part of that transaction
will be permanently written to the data source. If the transaction is rolled back, all of the
commands will be discarded at the data source.
Although it isn’t possible to have two transactions on a single Connection, the OleDbTransaction object supports nested transactions. (They aren’t supported on SQL Server.) Nested Transactions is available only for OleDbTransaction class, not for the SqlTransaction class. Note that the OleDb managed
providers for SQL Server and MS-Access do not support nested transactions.
子事务的提交与回滚,只会影响其本身及其子事务。父事务回滚,则会将其所有子事务一起回滚,即使子事务已经提交。
All nested transactions must be committed or rolled back before the trans-action
containing them is committed; however, if the parent (containing) transaction is rolled
back, the nested transactions will also be rolled back, even if they have previously been
committed.
once the transaction is committed or rolled back, the transaction reference in any commands that participated in the transaction will be reset to Nothing
Note that once we have started a transaction on a certain connection, all the queries that use that particular
connection must fall inside the boundary of the transaction.
A transaction should be completed as soon as possible. An active transaction puts locks on various resources involved, so, it is always a good practice to keep transactions as small as possible. If you are selecting data within a transaction, then you should only SELECT the rows you really require.
Oracle offers the read committed and serializable isolation levels, as well as a read-only mode that is not part of SQL92. Read committed is the default.
Simultaneous ADO.NET and DBMS Transactions
Although rare, we might encounter cases where we are using ADO.NET transactions as well as DBMS
transactions. Suppose that we have one stored procedure that uses transactions internally, and you are calling
this stored procedure as a part of your own ADO.NET transaction. In such cases, both the transactions work as
if they are nested. In such cases, the ADO.NET commit or rollback decides the outcome of the entire process.
However, there are chances of getting into errors if you rolled back from the stored procedure, or placed
improper nesting levels.
By default, if you do not explicitly commit the transaction, then the transaction is rolled back.
2、空值问题,System.DBNull,datagrid中,对于字符字段不能把没有录入作为null处理,当作为""字符。
3、数据库访问安全问题,就是connectionstring的安全问题
4、null值处理问题,任何对象、返回值,都应要考虑null的情况
5、dbnull的处理问题
6、basedataset的使用,如果共同使用同一个basedataset实例,则要小心datatable的命名,尽量不要重复。
7、对于主从、主从从表的标志字段,如果从表中需要这个标志字段来控制输入以及其他相关性操作,则从表中应该加上这个标志字段,以冗余获取编程控制的方便。
8、对于通过dataset来更新数据的时候,不能在更新后,采用其他方式更新数据,否则再通过此dataset进行更新操作的时候,会报updatecommand并发错误。
9、datareader在关闭之前,不能再用同一个connection打开另一个datareader。

浙公网安备 33010602011771号