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
|
.....
cnx.Open()
Dim sqlTran As SqlTransaction = cnx.BeginTransaction()
Dim cmdInsertPrix As SqlCommand = cnx.CreateCommand()
cmdInsertPrix.Transaction = sqlTran
cmdInsertPrix.Parameters.Add("@idarticle", SqlDbType.Int).Value = Val(lblSKU.Text)
cmdInsertPrix.Parameters.Add("@apdatedebut", SqlDbType.SmallDateTime).Value = dgvPrix.Rows(k).Cells("apdatedebut").Value
cmdInsertPrix.Parameters.Add("@apdatefin", SqlDbType.SmallDateTime).Value = dgvPrix.Rows(k).Cells("apdatefin").Value
cmdInsertPrix.Parameters.Add("@apprixachat", SqlDbType.SmallMoney).Value = dgvPrix.Rows(k).Cells("apprixachat").Value
cmdInsertPrix.Parameters.Add("@apprixbase", SqlDbType.SmallMoney).Value = dgvPrix.Rows(k).Cells("apprixbase").Value
Try
cmdInsertPrix.CommandText = "UPDATE articles_prix SET apdatefin=@apdatefin WHERE idarticle=@idarticle and apdatedebut=@apdatedebut;" + "INSRT INTO articles_prix(idarticle,apdatedebut,apdatefin,apprixachat,apprixbase) VALUES(@idarticle,@apdatedebut,@apdatefin,@apprixachat,@apprixbase)"
cmdInsertPrix.ExecuteNonQuery()
sqlTran.Commit()
MessageBox.Show("Transaction executée avec succès!")
cnx.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
cnx.Close()
Try
sqlTran.Rollback()
Catch exRollback As Exception
MessageBox.Show(exRollback.Message)
cnx.Close()
End Try
Exit sub
End Try
... |
Partager