1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
PrivateSub saveDF(ByVal ds As DataSet, ByVal ReferenceDF AsString)
Dim cntByDF AsInteger
cntByDF = ds.Tables(0).Rows.Count
Dim sSQL AsString
Dim transact As OleDb.OleDbTransaction
Dim cn2 AsNew OleDb.OleDbConnection
Dim cmd2 AsNew OleDb.OleDbCommand
If cn2.State = ConnectionState.Closed Then
cn2.ConnectionString = chaineConnexion(userI5, pwdI5)
cn2.Open()
EndIf
transact = cn2.BeginTransaction
cmd2.Transaction = transact
cmd2.Connection = cn2
Try
For j AsInteger = 0 To cntByDF - 1
sSQL = " INSERT INTO DF_DUPLIC VALUES " & _
" ('85',current date,'" & ReferenceDF & "','" & ds.Tables(0).Rows(j).Item("champ1") & "', " & _
" '" & ds.Tables(0).Rows(j).Item("champ2") & "', " & _
" '', " & _
" '" & ds.Tables(0).Rows(j).Item("champ3") & "', " & _
" '" & ds.Tables(0).Rows(j).Item("champ4") & "', " & _
" '" & ds.Tables(0).Rows(j).Item("champ5") & "', " & _
" '" & moduleName & "', " & _
" '" & ds.Tables(0).Rows(j).Item("champ6") & "' " & _
" )"
cmd2.CommandText = sSQL
cmd2.ExecuteNonQuery()
Next
transact.Commit()
Catch ex As Exception
transact.Rollback()
MsgBox(ex.Message)
Finally
cn2.Close()
EndTry
EndSub
|
Partager