Programación en 3 Capas: Restricción FK en Visual Basic con SQL Server
Publicado por Jonathan (3 intervenciones) el 05/11/2020 00:50:05
Hola a todos, estado intentado realizar un UPDATE a un registro través de programación en 3 capas, donde cambiara el Status (enviado a prueba) al nuevo status (prueba terminada)
El siguiente mensaje es el error con el que cuento.
The UPDATE statement conflicted with the FOREIGN KEY constraint FK_P_Pruebas_S_PruebasStatus. The conflict occurred in database dbProcesoDesarrollo, table dbo.S_PruebasStatus, column IdPruebaStatus.The statement has been terminated.The statement has been terminated.
Aquí el código en aspx.vb en el cual implemento para cambiar el status
Código para validar que el dato no de duplique desde Visual Basic
Código SQL



El siguiente mensaje es el error con el que cuento.
The UPDATE statement conflicted with the FOREIGN KEY constraint FK_P_Pruebas_S_PruebasStatus. The conflict occurred in database dbProcesoDesarrollo, table dbo.S_PruebasStatus, column IdPruebaStatus.The statement has been terminated.The statement has been terminated.
Aquí el código en aspx.vb en el cual implemento para cambiar el status
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
Private Sub TerminarPruebaAtender()
Try
Using oDesarrollador As New libPruebas.PruebaSystem.rnPruebas
oDesarrollador.Activo = 1
oDesarrollador.IdPrueba = rgrdPruebaTester.SelectedValue
oDesarrollador.IdPrueba = hidIdPrueba.Value
oDesarrollador.ValidarEnvio()
If oDesarrollador.objError.bError Then
Throw oDesarrollador.objError.uException
End If
If oDesarrollador.bValido Then
oDesarrollador.PruebaTerminada()
If oDesarrollador.objError.bError Then
Throw oDesarrollador.objError.uException
End If
rgrdPruebaTester.Rebind()
RadMsgBox(rwinManager, "Módulo Terminado", "Guardado correcto", clssMensaje.eImgMessage.Exitoso)
rgrdPruebaTester.Rebind()
Else
RadMsgBox(rwinManager, "Error al enviar", "Erro al Enviar", clssMensaje.eImgMessage.Alert)
End If
End Using
Catch ex As Exception
RadMsgBox(rwinManager, "Problemas al Cambiar de Etapa el Módulo, intente nuevamente", "Problemas de Etapa", clssMensaje.eImgMessage.Error, ex)
End Try
End Sub
Código para validar que el dato no de duplique desde Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
Public Function ValidarEnvio() As Boolean
Bandera = "s1"
dt = Listar()
If dt.Rows.Count > 0 Then
bValido = False
Return False
Else
bValido = True
Return True
End If
End Function
Código SQL
1
2
3
4
5
if @Bandera = 's1'
Begin
SELECT * FROM P_Pruebas WHERE IdPruebaStatus = @IdPruebaStatus
and activo=1 and IdPrueba <> @IdPrueba
End



Valora esta pregunta


0