Error con Datareader
Publicado por miraloyvete (39 intervenciones) el 25/07/2011 18:05:14
Hola
Tengo el siguiente codigo con el siguiente orden:
Dim conexion As New NpgsqlConnection()
Dim comando, comando1 As New NpgsqlCommand()
Dim lector, lector1 As NpgsqlDataReader
Try
conexion.ConnectionString = cad_con
conexion.Open()
comando.Connection = conexion
comando.CommandType = CommandType.Text
comando.CommandText = "select DISTINCT(palet) From m_palets"
lector = comando.ExecuteReader()
While lector.Read()
'Oculto el palet de 0 si no devuelve nada
If Convert.ToString(lector(0)) = "" Then
OcultarPalet((0))
'
Exit Sub
End If
p = CInt(lector(0))
pindex = pindex + 1
comando1.Connection = conexion
comando1.CommandType = CommandType.Text
comando1.CommandText = "SELECT matricula,bultos FROM m_relconp WHERE palet=" & CStr(p)
lector1 = comando1.ExecuteReader()
While lector1.Read()
'meto el item, primero la cantidad
Palet_ed(pindex).Item(0, i).Value = Convert.ToString(lector1(1))
'luego el nombre del articulos
Palet_ed(pindex).Item(0, i).Value = Convert.ToString(lector1(0))
'en el tag guardo la matricula
Palet_ed(pindex).Item(0, i).Tag = matri
End While
lector1.Close()
MostrarPagina() 'me voy a la pagina
End While
lector.Close()
Me da el siguiente error y no se como solucionarlo:
"There is already open datareader associated with this command which must be closed first"
Tengo el siguiente codigo con el siguiente orden:
Dim conexion As New NpgsqlConnection()
Dim comando, comando1 As New NpgsqlCommand()
Dim lector, lector1 As NpgsqlDataReader
Try
conexion.ConnectionString = cad_con
conexion.Open()
comando.Connection = conexion
comando.CommandType = CommandType.Text
comando.CommandText = "select DISTINCT(palet) From m_palets"
lector = comando.ExecuteReader()
While lector.Read()
'Oculto el palet de 0 si no devuelve nada
If Convert.ToString(lector(0)) = "" Then
OcultarPalet((0))
'
Exit Sub
End If
p = CInt(lector(0))
pindex = pindex + 1
comando1.Connection = conexion
comando1.CommandType = CommandType.Text
comando1.CommandText = "SELECT matricula,bultos FROM m_relconp WHERE palet=" & CStr(p)
lector1 = comando1.ExecuteReader()
While lector1.Read()
'meto el item, primero la cantidad
Palet_ed(pindex).Item(0, i).Value = Convert.ToString(lector1(1))
'luego el nombre del articulos
Palet_ed(pindex).Item(0, i).Value = Convert.ToString(lector1(0))
'en el tag guardo la matricula
Palet_ed(pindex).Item(0, i).Tag = matri
End While
lector1.Close()
MostrarPagina() 'me voy a la pagina
End While
lector.Close()
Me da el siguiente error y no se como solucionarlo:
"There is already open datareader associated with this command which must be closed first"
Valora esta pregunta


0