Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/04/2013, 02:58
maialenlopez
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 10 meses
Puntos: 7
Respuesta: filas y columnas de la tabla

Solucionado. La solución era el crear los objrow y objcell dentro del try para que cada vez que tenga que volver a hacer el try se creen objrow y objcell nuevos. Os dejo el código para que podais verlo mejor, y por si a alguien le sirve.

Código vb.net:
Ver original
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.         Dim conn As New MySqlConnection
  3.         conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("conexionMySQL").ConnectionString
  4.         Dim mysql_comando As New MySqlCommand("Select distinct noperario,operario from cdp_operaciones where noperario = 2177", conn)
  5.         Dim reader As MySqlDataReader
  6.         Dim da As New MySqlDataAdapter(mysql_comando)
  7.         Dim numoperario, longitud1, longitud2, longitud3, longitud4, i, j, tiempoteorico, totalCapturadas, capturadas As Integer
  8.         Dim nombre, mes, fechaActual, reglaplantrabajo, mesActual, anoActual, fecha, horas As String
  9.         Dim tpr29, tpr30, tpr31 As String
  10.         Dim tiempotprX As Integer
  11.         Dim valoresarray1, valoresarray2, valoresarray3, valoresarray4 As String()
  12.         Dim objRow As New TableRow()
  13.         fechaActual = Now.Date
  14.         mesActual = Month(fechaActual)
  15.         anoActual = Year(fechaActual)
  16.         fecha = mesActual + "/" + anoActual
  17.         i = 0
  18.         j = 0
  19.  
  20.         valoresarray1 = calculoFechaHorasReales(numoperario, fechaActual)
  21.         longitud1 = valoresarray1.Length
  22.         reglaplantrabajo = calculoReglaPlanTrabajo(numoperario, fechaActual)
  23.         valoresarray2 = calculoPeriodosTrabajo(reglaplantrabajo, fechaActual)
  24.         longitud2 = valoresarray2.Length
  25.  
  26.         For i = 0 To longitud1 - 1
  27.             tiempoteorico = 0
  28.             Try
  29.                 objRow = New TableRow
  30.                 Dim objCell1, objCell2, objCell3, objCell4, objCell5, objCell6, objCell7, objCell8 As New TableCell()
  31.                 Using conn
  32.                     conn.Open()
  33.                     With mysql_comando
  34.                         reader = .ExecuteReader()
  35.                         While reader.Read()
  36.                             numoperario = reader.GetValue(0)
  37.                             nombre = reader.GetValue(1)
  38.                             mes = fecha
  39.                             objCell1.Controls.Add(New LiteralControl(numoperario))
  40.                             objCell1.HorizontalAlign = HorizontalAlign.Center
  41.                             objCell2.Controls.Add(New LiteralControl(nombre))
  42.                             objCell2.HorizontalAlign = HorizontalAlign.Center
  43.                             'objCell3.Controls.Add(New LiteralControl(mes))
  44.                             objCell3.Controls.Add(New LiteralControl(valoresarray1(i)))
  45.                             objCell3.HorizontalAlign = HorizontalAlign.Center
  46.                             objRow.Cells.Add(objCell1)
  47.                             objRow.Cells.Add(objCell2)
  48.                             objRow.Cells.Add(objCell3)
  49.                         End While
  50.                         .Dispose()
  51.                     End With                  
  52.                     objCell5.Controls.Add(New LiteralControl("%"))
  53.                     objCell5.HorizontalAlign = HorizontalAlign.Center
  54.                     objRow.Cells.Add(objCell5)
  55.                     horas = calcularHorasDia(valoresarray1(i))
  56.                     Dim longitud5, longitud6, longitud7 As Integer
  57.                     Dim h, minCortar, min, s, horasdia As String
  58.                     longitud5 = horas.Length
  59.                     If longitud5 = 5 Then
  60.                         h = horas.Substring(0, 1)
  61.                         minCortar = horas.Substring(0, 3)
  62.                         longitud6 = minCortar.Length
  63.                         min = Right(minCortar, longitud6 - 1)
  64.                         s = Right(horas, longitud5 - 3)
  65.                         horasdia = h + ":" + min + ":" + s
  66.                     ElseIf longitud5 = 6 Then
  67.                         h = horas.Substring(0, 2)
  68.                         minCortar = horas.Substring(0, 4)
  69.                         longitud6 = minCortar.Length
  70.                         min = Right(minCortar, longitud6 - 2)
  71.                         s = Right(horas, longitud5 - 4)
  72.                         horasdia = h + ":" + min + ":" + s
  73.                     End If
  74.                     objCell6.Controls.Add(New LiteralControl(horasdia))
  75.                     'objCell6.Controls.Add(New LiteralControl("horasReales"))
  76.                     objCell6.HorizontalAlign = HorizontalAlign.Center
  77.                     objRow.Cells.Add(objCell6)
  78.  
  79.                     objCell7.Controls.Add(New LiteralControl("%"))
  80.                     objCell7.HorizontalAlign = HorizontalAlign.Center
  81.                     objRow.Cells.Add(objCell7) 'porcentaje horas reales
  82.  
  83.                     Dim long1, long2 As Integer
  84.                     Dim ano, mesCortar, mes1, dia, fechaformato As String
  85.  
  86.                     long1 = valoresarray1(i).Length
  87.                     dia = Right(valoresarray1(i), longitud1 - 8)
  88.  
  89.                     If dia = "01" Then
  90.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(0))
  91.                     ElseIf dia = "02" Then
  92.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(1))
  93.                     ElseIf dia = "03" Then
  94.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(2))
  95.                     ElseIf dia = "04" Then
  96.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(3))
  97.                     ElseIf dia = "05" Then
  98.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(4))
  99.                     ElseIf dia = "06" Then
  100.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(5))
  101.                     ElseIf dia = "07" Then
  102.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(6))
  103.                     ElseIf dia = "08" Then
  104.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(7))
  105.                     ElseIf dia = "09" Then
  106.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(8))
  107.                     ElseIf dia = "10" Then
  108.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(9))
  109.                     ElseIf dia = "11" Then
  110.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(10))
  111.                     ElseIf dia = "12" Then
  112.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(11))
  113.                     ElseIf dia = "13" Then
  114.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(12))
  115.                     ElseIf dia = "14" Then
  116.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(13))
  117.                     ElseIf dia = "15" Then
  118.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(14))
  119.                     ElseIf dia = "16" Then
  120.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(15))
  121.                     ElseIf dia = "17" Then
  122.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(16))
  123.                     ElseIf dia = "18" Then
  124.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(17))
  125.                     ElseIf dia = "19" Then
  126.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(18))
  127.                     ElseIf dia = "20" Then
  128.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(19))
  129.                     ElseIf dia = "21" Then
  130.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(20))
  131.                     ElseIf dia = "22" Then
  132.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(21))
  133.                     ElseIf dia = "23" Then
  134.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(22))
  135.                     ElseIf dia = "24" Then
  136.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(23))
  137.                     ElseIf dia = "25" Then
  138.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(24))
  139.                     ElseIf dia = "26" Then
  140.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(25))
  141.                     ElseIf dia = "27" Then
  142.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(26))
  143.                     ElseIf dia = "28" Then
  144.                         tiempotprX = calcularTiempoTeoricoDia(valoresarray2(27))
  145.                     ElseIf dia = "29" Then
  146.                         If tpr29 <> " " Then
  147.                             tiempotprX = calcularTiempoTeoricoDia(valoresarray2(28))
  148.                         End If
  149.                     ElseIf dia = "30" Then
  150.                         If tpr30 <> " " Then
  151.                             tiempotprX = calcularTiempoTeoricoDia(valoresarray2(29))
  152.                         End If
  153.                     ElseIf dia = "31" Then
  154.                         If tpr31 <> " " Then
  155.                             tiempotprX = calcularTiempoTeoricoDia(valoresarray2(30))
  156.                         End If
  157.                     End If
  158.  
  159.                     tiempoteorico = tiempotprX
  160.                     objCell8.Controls.Add(New LiteralControl(tiempoteorico))
  161.                     objCell8.HorizontalAlign = HorizontalAlign.Center
  162.                     objRow.Cells.Add(objCell8) 'horas teoricas
  163.                 End Using
  164.             Catch ex As Exception
  165.                 MsgBox("Error en BD" & Chr(13) & Chr(13) & ex.Message)
  166.             Finally
  167.                 conn.Close()
  168.                 conn.Dispose()
  169.             End Try
  170.             Table1.Rows.Add(objRow)
  171.         Next
  172.     End Sub


Un saludo
__________________
Gracias por todo;

Un saludo