Bonjour a tous,
Pouriez vous m'aider a Faire un DELETE dans un base de donnée car je me rend fou!
Sa parai simple mais je ne comprend pas alors voici le bou de code qui me me permet pas de le faire:
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
| Public Class Delete()
Public CNX As SqlClient.SqlConnection
Public CMD As SqlClient.SqlCommand
Public DA As SqlClient.SqlDataAdapter
Public DS As New DataSet
Public R_SQL As String
Public Function Supp(ByVal tab As String)
R_SQL = "DELETE FROM Effectif WHERE NumCQ_EFFECTIF LIKE '" & tab & "'"
With CMD
.CommandText = R_SQL
.Connection.Open()
.ExecuteNonQuery()
.Connection.Close()
End With
With DA
.SelectCommand = CMD
.Fill(DS, "DEL")
End With
Return DS
End Function
End class |
Se serais simpas de me repondre car je me prend la tete avec sa depuis 2 jours.
PS: Le message d'erreur est le suivant :
The DELETE statement conflicted with the REFERENCE constraint "FK_PRATIQUE_PRATIQUER_EFFECTIF". The conflict occurred in database "Projet", table "dbo.PRATIQUER", column 'NUMCQ_EFFECTIF'. The statement has been terminated.
Config VB.ET Visual Studio 2008 et SQL Serveur 2005 Express.
Quand je fai la command de suppression dans SQL serveur il me retourne :
1 2 3
| Msg 547, Level 16, State 0, Line 1
The DELETE statement conflicted with the REFERENCE constraint "FK_PRATIQUE_PRATIQUER_EFFECTIF". The conflict occurred in database "Projet", table "dbo.PRATIQUER", column 'NUMCQ_EFFECTIF'.
The statement has been terminated. |
Je pense plutot à une erreur de SQL.
Merci a tous
Partager