OdbcTransaction.Rollback 方法的VB.NET例子
来源:互联网 发布:基站 知乎 编辑:程序博客网 时间:2024/05/17 06:27
OdbcTransaction.Rollback 方法的VB.NET例子
下面的示例创建一个 OdbcConnection 和一个 OdbcTransaction 。此示例还演示如何使用 BeginTransaction、Commit 和 Rollback 等方法。
Public Sub ExecuteTransaction(ByVal connectionString As String) Using connection As New OdbcConnection(connectionString) Dim command As New OdbcCommand() Dim transaction As OdbcTransaction ' Set the Connection to the new OdbcConnection. command.Connection = connection ' Open the connection and execute the transaction. Try connection.Open() ' Start a local transaction. transaction = connection.BeginTransaction() ' Assign transaction object for a pending local transaction. command.Connection = connection command.Transaction = transaction ' Execute the commands. command.CommandText = _ "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')" command.ExecuteNonQuery() command.CommandText = _ "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')" command.ExecuteNonQuery() ' Commit the transaction. transaction.Commit() Console.WriteLine("Both records are written to database.") Catch ex As Exception Console.WriteLine(ex.Message) ' Try to rollback the transaction Try transaction.Rollback() Catch ' Do nothing here; transaction is not active. End Try End Try ' The connection is automatically closed when the ' code exits the Using block. End UsingEnd Sub
- OdbcTransaction.Rollback 方法的VB.NET例子
- Process.GetCurrentProcess 方法的VB.NET例子
- Hibernate的rollback方法
- [VB.NET]要个VB.NET的Socket使用例子
- DataGridView.CellValidating 事件的VB.NET例子
- DataGrid.DataSource 属性的VB.NET例子
- vb.net多线程例子
- 身份验证例子(VB.NET)
- VB.NET串口通信例子
- VB.NET可选参数例子
- VB.NET串口通信例子
- rollback练习小例子
- 在ASP.NET中操作文件的例子(VB)
- VB.NET 中 使用 ListView 控件的简单例子
- VB.NET 中 使用 ListView 控件的简单例子
- 在ASP.NET中操作文件的例子(VB)
- [VB.NET]询异步socket通信完善的例子.
- VB.NET中使用ListView控件的简单例子
- 该如何去学编程
- 批处理命令大全
- OO
- 调查研究函数传递调用几次是最合适的
- 删除金甲等管理软件
- OdbcTransaction.Rollback 方法的VB.NET例子
- 自定义checkbox大小(注:用CSS的ZOOM属性 )
- javascript IP地址控件和MAC地址控件
- Java关闭窗体的六种方法
- 自己打造动网博客二级域名系统
- 冒泡排序法证明
- javax.microedition.lcdui(1)
- 说句实话真的就那么难吗?
- PCTFREE and PCTUSED Tips