Issues with oracle 10g, stored procedures and webservice

garrapatita

New member
Joined
Jun 5, 2009
Messages
1
Programming Experience
5-10
Hello everyone!

I'm developing a webservice that connects with an oracle 10g and calls some stored procedures. The thing is that I can't get this to work when i call them from my client which is a winform that consumes the webservice.

I want to store a picture in a table, for that purpose i made this sp in my oracle 10g database:

CREATE OR REPLACE PROCEDURE N_guardarFoto(
CodLibro_ IN INTEGER,
CodOficina_ IN INTEGER,
Anho_ IN INTEGER,
TomoNumero_ IN INTEGER,
ActaNumero_ IN INTEGER,
Imagen1_ IN BLOB,
Usu_ IN VARCHAR2,
NroPic_ IN INTEGER
)
IS

BEGIN

INSERT INTO N_NACIMIENTOSIMG (CODLIBRO, CODOFICINA, ANHO, TOMONUMERO,

ACTANUMERO, IMAGEN1) VALUES (CodLibro_, CodOficina_, Anho_,

TomoNumero_, ActaNumero_, Imagen1_);

END;
END;
/


Then I created a webmethod in an existent webservice

Public Function guardarFoto(ByVal codLibro_ As String, ByVal codOficina_ As String, ByVal Anho_ As String, ByVal tomoNro_ As String, ByVal actaNro_ As String, ByVal foto_ As Byte(), ByVal usu_ As String, ByVal nroPic_ As Integer) As String
Dim cl As Integer
Dim co As Integer
Dim anho As Integer
Dim tnro As Integer

cl = Integer.Parse(cl)
co = Integer.Parse(co)
anho = Integer.Parse(Anho_)
tnro = Integer.Parse(tomoNro_)


Dim conString As String = ConfigurationManager.AppSettings("ConexionDB").ToString()
Dim con As Oracle.DataAccess.Client.OracleConnection = New OracleConnection(conString)
Dim ctrl As Integer
Try
con.Open()
Dim spcmd As OracleCommand = New OracleCommand("N_guardarFoto", con)
spcmd.CommandType = CommandType.StoredProcedure
'spcmd.Connection = con
spcmd.Parameters.Add("CodLibro_", OracleDbType.Int32, cl, ParameterDirection.Input)
spcmd.Parameters.Add("CodOficina_", OracleDbType.Int32, co, ParameterDirection.Input)
spcmd.Parameters.Add("Anho_", OracleDbType.Int32, anho, ParameterDirection.Input)
spcmd.Parameters.Add("TomoNumero_", OracleDbType.Int32, tnro, ParameterDirection.Input)
spcmd.Parameters.Add("ActaNumero_", OracleDbType.Int32, actaNro_, ParameterDirection.Input)
spcmd.Parameters.Add("Imagen1_", OracleDbType.Blob, foto_, ParameterDirection.Input)
spcmd.Parameters.Add("Usu_", OracleDbType.Varchar2, usu_, ParameterDirection.Input)
spcmd.Parameters.Add("NroPic_", OracleDbType.Int32, nroPic_, ParameterDirection.Input)
ctrl = spcmd.ExecuteNonQuery()

Catch ex As Exception
Dim err As String = ex.ToString()
Return err
Finally
con.Close()
End Try
If ctrl > 0 Then
Return "El acta se ha digitalizado con exito"
Else
Return "El acta NO fue digitalizada correctamente"
End If
End Function

And the result from the executenonquery is always 0, it never performs the insert in the database.

For testing purposes I made a simpler webmethod as well and it also has the same problem, when i call it from the testing page it works but when i call it from my winform it doesn't

Public Function existeActa(ByVal codLibro_ As String, ByVal codOficina_ As String, ByVal Anho_ As String, ByVal tomoNro_ As String, ByVal actaNro_ As String) As String
Dim cl As Integer
Dim co As Integer
Dim anho As Integer
Dim tnro As Integer

cl = Integer.Parse(codLibro_)
co = Integer.Parse(codOficina_)
anho = Integer.Parse(Anho_)
tnro = Integer.Parse(tomoNro_)
Dim retorno As Integer
Dim dr As OracleDataReader
Dim comando As String

Dim conString As String = ConfigurationManager.AppSettings("ConexionDB").ToString()
Dim con As OracleConnection = New OracleConnection(conString)

Try
con.Open()
comando = "Select count(codlibro) from pn_nacimientos where codlibro = " & cl & _
" and codoficina = " & co & " and anho = " & anho & " and tomonumero = " & tnro & _
" and actanumero like '" & actaNro_ & "'"
Dim cmd As OracleCommand = New OracleCommand(comando, con)
cmd.CommandType = CommandType.Text

retorno = Ctype(cmd.ExecuteScalar(), Integer)
Catch ex As Exception
return ex.tostring
Finally
'dr.Close()
con.Close()
End Try
return retorno.ToString

End Function
 
Back
Top