表示层:(页面.aspx.vb)
'在一个事务里Copy查询到的文件以及目录到选定的目录下面
Dim con As New OleDb.OleDbConnection()
Dim ObjTran As OleDb.OleDbTransaction '事务管理对象
Dim objPD As New PersonDoc(CType(Application("ConnectionString"), String))
Dim i As Integer, j As Integer, Intrtn As Int16
Dim Dstmp As DataSet
Dim Tr As DataRow
Try
For i = 0 To Tb_doc.Rows.Count - 1
Dstmp = New DataSet()
Dstmp = objPD.GetByPk(mDv_Doc.Item(i).Item("Docno"))
StrDocArr(0) = ""
.............................
objPD.AddDocCon(StrDocArr, Dstmp.Tables(0).Rows(0).Item("Docdetail"), con, ObjTran)
Next
ObjTran.Commit()
LblErrMag.Text = "复制成功"
LblErrMag.ForeColor = Color.FromArgb(0, 0, 255)
Catch E As Exception
ObjTran.Rollback()
LblErrMag.Text = "复制失败"
LblErrMag.ForeColor = Color.FromArgb(255, 0, 0)
Finally
If Not (con Is Nothing) Then
If Not (con.State = ConnectionState.Closed) Then
con.Close()
End If
End If
End Try