Visual Basic.NET - Ayuda para usar una funcion SQL2005 desde VBNET

 
Vista:

Ayuda para usar una funcion SQL2005 desde VBNET

Publicado por Edmundo (1 intervención) el 28/03/2007 15:54:33
Tengo que usar una funcion SQLServer2005 que devuelve registros.
Los registros los debo recuperar a través de un objeto "ADODB.Command" (usando VBNET2005)
Mi codigo es el siguiente:

Dim RSDeposito As ADODB.Recordset
Dim objComando As New ADODB.Command

Try
DesdeFecha = Convert.ToDateTime(txtDesdeFecha.Text)
HastaFecha = Convert.ToDateTime(txtHastaFecha.Text)

objComando.let_ActiveConnection(objConexion)
objComando.CommandText = "f_comprobante_deposito"
objComando.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc

objComando.Parameters.Refresh()
objComando.Parameters.Item("@grupo").Value = 12
objComando.Parameters.Item("@fecha_desde").Value = DesdeFecha
objComando.Parameters.Item("@fecha_hasta").Value = HastaFecha
RSDeposito = objComando.Execute() ' *** DA ERROR ***

Catch(ex as Exception)
' Atrapo el error
End Try
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ayuda para usar una funcion SQL2005 desde VBNET

Publicado por Harold Villena (411 intervenciones) el 28/03/2007 20:09:01
El problema es que debes crear el recordset con el NEW

Dim RSDeposito As New ADODB.Recordset
Dim objComando As New ADODB.Command

Try
DesdeFecha = Convert.ToDateTime(txtDesdeFecha.Text)
HastaFecha = Convert.ToDateTime(txtHastaFecha.Text)

objComando.let_ActiveConnection(objConexion)
objComando.CommandText = "f_comprobante_deposito"
objComando.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc

objComando.Parameters.Item("@grupo").Value = 12
objComando.Parameters.Item("@fecha_desde").Value = DesdeFecha
objComando.Parameters.Item("@fecha_hasta").Value = HastaFecha
RSDeposito = objComando.Execute()

Catch(ex as Exception)
' Atrapo el error
End Try
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar