PROBLEMA CON INSERTAR A UNA TABLA
Publicado por HECTORS (2 intervenciones) el 08/01/2008 16:20:05
HOL, TENGO UN PROBLEMA CON HACER UN INSERT EN SQL SERVER, DENTRO DE LA PROBLEMATICA PASA QUE ,E SALE UN AVISO QUE NO PUEDO PONER UN VALOR NVARCHAR EN UN TABLAS QUE NECESITA UN VALOR INTEGER, LO RARO QUE TENGO EL VALOR NVARCHAR EN LA TABLA Y NO ME LO IDENTIFICA
PROCEDIMIENTO
CREATE Procedure Graba_Despacho
@Nro_Orden nvarchar(50),
@Nro_Oficio nvarchar(50),
@Fld_Valor_P nvarchar(50),
@Fld_Total_A nvarchar(50),
@Fld_Total_S nvarchar(50),
@Id_Ingreso char(50),
@Fld_Desp nvarchar(50),
@Data smalldatetime
As
Begin
DECLARE
@graba char(1)
if @Fld_Desp >0
begin
INSERT INTO programas(Nro_Oficio, Nro_Orden, Fld_Desp,Fld_Valor_P, Fld_Total_A, Fld_Total_S, Id_Ingreso, Fecha)
VALUES (@Nro_Oficio, @Nro_Orden, @Fld_Desp, @Fld_Valor_P, @Fld_Total_A, @Fld_Total_S,@Id_Ingreso, @Data )
end
End
GO
PROGRAMA
Set ComandoSQL = New ADODB.Command
Set ComandoSQL.ActiveConnection = conecta
ComandoSQL.CommandText = "Graba_Despacho"
ComandoSQL.CommandType = adCmdStoredProc
On Error GoTo error_de_Busqueda:
Set P = ComandoSQL.CreateParameter("@Nro_Oficio", adChar, adParamInput, 50, Trim(Form1.NroOficio.Text))
Set P1 = ComandoSQL.CreateParameter("@Nro_Orden", adChar, adParamInput, 50, Trim(Form1.Orden.Text))
Set P2 = ComandoSQL.CreateParameter("@Fld_desp", adChar, adParamInput, 50, Trim(Form1.desp.Text))
Set P3 = ComandoSQL.CreateParameter("@Fld_Valor_P", adChar, adParamInput, 50, Trim(Form1.Txt_P.Text))
Set P4 = ComandoSQL.CreateParameter("@Fld_Total_A", adChar, adParamInput, 50, Trim(Form1.Txt_A.Text))
Set P5 = ComandoSQL.CreateParameter("@Fld_Valor_S", adChar, adParamInput, 50, Trim(Form1.Txt_S.Text))
Set P6 = ComandoSQL.CreateParameter("@Id_Ingreso", adChar, adParamInput, 50, Trim(Form1.servicio_cod.Text))
Set P7 = ComandoSQL.CreateParameter("@Fecha", adChar, adParamInput, 50, Trim(Form1.DTPicker1.Value))
ComandoSQL.Parameters.Append P
ComandoSQL.Parameters.Append P1
ComandoSQL.Parameters.Append P2
ComandoSQL.Parameters.Append P3
ComandoSQL.Parameters.Append P4
ComandoSQL.Parameters.Append P5
ComandoSQL.Parameters.Append P6
ComandoSQL.Parameters.Append P7
Set RecVal = ComandoSQL.Execute()
If RecVal.RecordCount = -1 Then
conecta.Close 'se cierra la conexion
error_de_Busqueda:
If Err.Number <> 0 Then
If Err.Number = 3021 Then
MsgBox "El Paciente no se Encuentra Registrado", vbCritical, "Sr Usuario"
Exit Function
Else
Msj = "Error # " & Str(Err.Number) & " fue generado por " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msj, , "Error", Err.HelpFile, Err.HelpContext
Exit Function
End If
End If
End If
PROCEDIMIENTO
CREATE Procedure Graba_Despacho
@Nro_Orden nvarchar(50),
@Nro_Oficio nvarchar(50),
@Fld_Valor_P nvarchar(50),
@Fld_Total_A nvarchar(50),
@Fld_Total_S nvarchar(50),
@Id_Ingreso char(50),
@Fld_Desp nvarchar(50),
@Data smalldatetime
As
Begin
DECLARE
@graba char(1)
if @Fld_Desp >0
begin
INSERT INTO programas(Nro_Oficio, Nro_Orden, Fld_Desp,Fld_Valor_P, Fld_Total_A, Fld_Total_S, Id_Ingreso, Fecha)
VALUES (@Nro_Oficio, @Nro_Orden, @Fld_Desp, @Fld_Valor_P, @Fld_Total_A, @Fld_Total_S,@Id_Ingreso, @Data )
end
End
GO
PROGRAMA
Set ComandoSQL = New ADODB.Command
Set ComandoSQL.ActiveConnection = conecta
ComandoSQL.CommandText = "Graba_Despacho"
ComandoSQL.CommandType = adCmdStoredProc
On Error GoTo error_de_Busqueda:
Set P = ComandoSQL.CreateParameter("@Nro_Oficio", adChar, adParamInput, 50, Trim(Form1.NroOficio.Text))
Set P1 = ComandoSQL.CreateParameter("@Nro_Orden", adChar, adParamInput, 50, Trim(Form1.Orden.Text))
Set P2 = ComandoSQL.CreateParameter("@Fld_desp", adChar, adParamInput, 50, Trim(Form1.desp.Text))
Set P3 = ComandoSQL.CreateParameter("@Fld_Valor_P", adChar, adParamInput, 50, Trim(Form1.Txt_P.Text))
Set P4 = ComandoSQL.CreateParameter("@Fld_Total_A", adChar, adParamInput, 50, Trim(Form1.Txt_A.Text))
Set P5 = ComandoSQL.CreateParameter("@Fld_Valor_S", adChar, adParamInput, 50, Trim(Form1.Txt_S.Text))
Set P6 = ComandoSQL.CreateParameter("@Id_Ingreso", adChar, adParamInput, 50, Trim(Form1.servicio_cod.Text))
Set P7 = ComandoSQL.CreateParameter("@Fecha", adChar, adParamInput, 50, Trim(Form1.DTPicker1.Value))
ComandoSQL.Parameters.Append P
ComandoSQL.Parameters.Append P1
ComandoSQL.Parameters.Append P2
ComandoSQL.Parameters.Append P3
ComandoSQL.Parameters.Append P4
ComandoSQL.Parameters.Append P5
ComandoSQL.Parameters.Append P6
ComandoSQL.Parameters.Append P7
Set RecVal = ComandoSQL.Execute()
If RecVal.RecordCount = -1 Then
conecta.Close 'se cierra la conexion
error_de_Busqueda:
If Err.Number <> 0 Then
If Err.Number = 3021 Then
MsgBox "El Paciente no se Encuentra Registrado", vbCritical, "Sr Usuario"
Exit Function
Else
Msj = "Error # " & Str(Err.Number) & " fue generado por " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msj, , "Error", Err.HelpFile, Err.HelpContext
Exit Function
End If
End If
End If
Valora esta pregunta


0