executereader returns nothing

18/02/2005 - 19:52 por Erick Villafuerte | Informe spam
hola tengo una consulta a una base de sql la cual me devuelve un nombre, en
sql funciona bien pero si la mando llamar desde ado.net el parametro de
salida me regresa "nothing" no se si sea en este foro o tenga que ir a un
foro de ado espero puedan ayudarme, gracias.

Preguntas similare

Leer las respuestas

#1 Alejandro Mesa
18/02/2005 - 20:01 | Informe spam
Erick,

No importa en que foro, pero si no posteas el codigo (t-sql y .net) creo que
no obtendras mucha ayuda.


AMB

"Erick Villafuerte" wrote:

hola tengo una consulta a una base de sql la cual me devuelve un nombre, en
sql funciona bien pero si la mando llamar desde ado.net el parametro de
salida me regresa "nothing" no se si sea en este foro o tenga que ir a un
foro de ado espero puedan ayudarme, gracias.



Respuesta Responder a este mensaje
#2 Erick Villafuerte
18/02/2005 - 21:48 | Informe spam
Aqui esta el codigo de sql:

ALTER PROCEDURE dbo.GetFactura

(
@ID integer,
@Nombre char(50) output
)

AS
declare @NoProv integer

select @NoProv = Prov from Facturas where ID=@ID order by Prov


select * from Facturas where ID=@ID

select ID, Folio from Folios where Documento=@ID and Factura = 1

select * from Detalle where Documento=@ID and Factura=1

if @NoProv=9
begin
select @Nombre = Nombre from NomVarios_Facts where Factura=@ID
end
else
begin
select @Nombre= Nombre from Proveedores where Prov = @NoProv
end

RETURN

y este es el codigo de VB.NET:

Dim Cn As New SqlConnection(db("Control"))
Dim Cm As New SqlCommand
Cn.Open()
Try
With Cm
.Connection = Cn
.CommandType = CommandType.StoredProcedure
.CommandText = "GetFactura"
.Parameters.Add("@ID", crit.ID)
Dim PNom As SqlParameter = .Parameters.Add("@Nombre",
SqlDbType.VarChar)
PNom.Size = 50
PNom.Direction = ParameterDirection.Output
PNom.Value = ""
Dim dr As New SafeDataReader(.ExecuteReader)
Try
If dr.Read Then
mID = crit.ID
Proveedor = Proveedor.GetProveedor(dr.GetInt32(1))
Fecha = dr.GetSmartDate(2, True).Date
Importe = dr.GetDouble(3)
'En la linea siguiente truena el programa porque PNom.Value=Nothing
NombreProv = PNom.Value.ToString

Gracias!
Respuesta Responder a este mensaje
#3 Erick Villafuerte
18/02/2005 - 22:39 | Informe spam
El codigo mostrado en el mensaje anterior es erroneo este es el que tengo:

Aqui esta el codigo de sql:

ALTER PROCEDURE dbo.GetFactura

(
@ID integer,
@Nombre char(50) output
)

AS
declare @NoProv integer

select @NoProv = Prov from Facturas where ID=@ID order by Prov


select * from Facturas where ID=@ID

select ID, Folio from Folios where Documento=@ID and Factura = 1

select * from Detalle where Documento=@ID and Factura=1

if @NoProv=9
begin
select @Nombre = Nombre from NomVarios_Facts where Factura=@ID
end
else
begin
select @Nombre= Nombre from Proveedores where Prov = @NoProv
end

RETURN

y este es el codigo de VB.NET:

Dim Cn As New SqlConnection(db("Control"))
Dim Cm As New SqlCommand
Cn.Open()
Try
With Cm
.Connection = Cn
.CommandType = CommandType.StoredProcedure
.CommandText = "GetFactura"
.Parameters.Add("@ID", crit.ID)
Dim PNom As SqlParameter = .Parameters.Add("@Nombre",
SqlDbType.Char) "el tipo de variable es char en el anterior decia VarChar"
PNom.Size = 50
PNom.Direction = ParameterDirection.Output
"esta linea esta comentada" Pnom.Value = ""
Dim dr As New SafeDataReader(.ExecuteReader)
Try
If dr.Read Then
mID = crit.ID
Proveedor = Proveedor.GetProveedor(dr.GetInt32(1))
Fecha = dr.GetSmartDate(2, True).Date
Importe = dr.GetDouble(3)
'En la linea siguiente truena el programa porque PNom.Value=Nothing
NombreProv = PNom.Value.ToString

Gracias!
Respuesta Responder a este mensaje
#4 Alejandro Mesa
19/02/2005 - 01:33 | Informe spam
Erick,

Trata cerrando el datareader antes de accesar al parametro de salida.


AMB

"Erick Villafuerte" wrote:

El codigo mostrado en el mensaje anterior es erroneo este es el que tengo:

Aqui esta el codigo de sql:

ALTER PROCEDURE dbo.GetFactura

(
@ID integer,
@Nombre char(50) output
)

AS
declare @NoProv integer

select @NoProv = Prov from Facturas where ID=@ID order by Prov


select * from Facturas where ID=@ID

select ID, Folio from Folios where Documento=@ID and Factura = 1

select * from Detalle where Documento=@ID and Factura=1

if @NoProv=9
begin
select @Nombre = Nombre from NomVarios_Facts where Factura=@ID
end
else
begin
select @Nombre= Nombre from Proveedores where Prov = @NoProv
end

RETURN

y este es el codigo de VB.NET:

Dim Cn As New SqlConnection(db("Control"))
Dim Cm As New SqlCommand
Cn.Open()
Try
With Cm
.Connection = Cn
.CommandType = CommandType.StoredProcedure
.CommandText = "GetFactura"
.Parameters.Add("@ID", crit.ID)
Dim PNom As SqlParameter = .Parameters.Add("@Nombre",
SqlDbType.Char) "el tipo de variable es char en el anterior decia VarChar"
PNom.Size = 50
PNom.Direction = ParameterDirection.Output
"esta linea esta comentada" Pnom.Value = ""
Dim dr As New SafeDataReader(.ExecuteReader)
Try
If dr.Read Then
mID = crit.ID
Proveedor = Proveedor.GetProveedor(dr.GetInt32(1))
Fecha = dr.GetSmartDate(2, True).Date
Importe = dr.GetDouble(3)
'En la linea siguiente truena el programa porque PNom.Value=Nothing
NombreProv = PNom.Value.ToString

Gracias!



Respuesta Responder a este mensaje
#5 Erick Villafuerte
21/02/2005 - 18:33 | Informe spam
Muchas gracias alejandro, lo hice y funciono muy bien.


"Alejandro Mesa" escribió en el
mensaje news:
Erick,

Trata cerrando el datareader antes de accesar al parametro de salida.


AMB

"Erick Villafuerte" wrote:

El codigo mostrado en el mensaje anterior es erroneo este es el que
tengo:

Aqui esta el codigo de sql:

ALTER PROCEDURE dbo.GetFactura

(
@ID integer,
@Nombre char(50) output
)

AS
declare @NoProv integer

select @NoProv = Prov from Facturas where ID=@ID order by Prov


select * from Facturas where ID=@ID

select ID, Folio from Folios where Documento=@ID and Factura = 1

select * from Detalle where Documento=@ID and Factura=1

if @NoProv=9
begin
select @Nombre = Nombre from NomVarios_Facts where Factura=@ID
end
else
begin
select @Nombre= Nombre from Proveedores where Prov = @NoProv
end

RETURN

y este es el codigo de VB.NET:

Dim Cn As New SqlConnection(db("Control"))
Dim Cm As New SqlCommand
Cn.Open()
Try
With Cm
.Connection = Cn
.CommandType = CommandType.StoredProcedure
.CommandText = "GetFactura"
.Parameters.Add("@ID", crit.ID)
Dim PNom As SqlParameter = .Parameters.Add("@Nombre",
SqlDbType.Char) "el tipo de variable es char en el anterior decia
VarChar"
PNom.Size = 50
PNom.Direction = ParameterDirection.Output
"esta linea esta comentada" Pnom.Value = ""
Dim dr As New SafeDataReader(.ExecuteReader)
Try
If dr.Read Then
mID = crit.ID
Proveedor = Proveedor.GetProveedor(dr.GetInt32(1))
Fecha = dr.GetSmartDate(2, True).Date
Importe = dr.GetDouble(3)
'En la linea siguiente truena el programa porque PNom.Value=Nothing
NombreProv = PNom.Value.ToString

Gracias!



email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida