Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/04/2013, 01:59
maialenlopez
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 10 meses
Puntos: 7
Exclamación filas y columnas de la tabla

Hola,
estoy programando en vb.net y tengo el siguiente problema.

si pongo lo siguiente, la tabla se pone correctamente:
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 noperario,operario,inicio from cdp_operaciones where noperario = 9152", conn)
  5.         Dim reader As MySqlDataReader
  6.         Dim da As New MySqlDataAdapter(mysql_comando)
  7.         Dim numoperario As Integer
  8.         Dim nombre, mes, fechaActual, reglaplantrabajo, mesActual, anoActual, fecha, horas As String
  9.         Dim inicio As Date
  10.         Dim objRow As New TableRow()
  11.         Dim objCell1, objCell2, objCell3, objCell4, objCell5, objCell6, objCell7, objCell8 As New TableCell()
  12.  
  13.         fechaActual = Now.Date
  14.         mesActual = Month(fechaActual)
  15.         anoActual = Year(fechaActual)
  16.         fecha = mesActual + "/" + anoActual
  17.  
  18.         Try
  19.                 Using conn
  20.                     conn.Open()
  21.                     With mysql_comando
  22.                         reader = .ExecuteReader()
  23.                         While reader.Read()
  24.                             numoperario = reader.GetValue(0)
  25.                             nombre = reader.GetValue(1)
  26.                             mes = fecha
  27.                             inicio = reader.GetValue(2)
  28.                             objCell1.Controls.Add(New LiteralControl(numoperario))
  29.                             objCell2.Controls.Add(New LiteralControl(nombre))
  30.                             objCell3.Controls.Add(New LiteralControl(mes))
  31.                             objCell4.Controls.Add(New LiteralControl(inicio))
  32.                             objRow.Cells.Add(objCell1)
  33.                             objRow.Cells.Add(objCell2)
  34.                             objRow.Cells.Add(objCell3)
  35.                             objRow.Cells.Add(objCell4)
  36.                         End While
  37.                         .Dispose()
  38.                     End With
  39.                 End Using
  40.             Catch ex As Exception
  41.                 MsgBox("Error en BD" & Chr(13) & Chr(13) & ex.Message)
  42.             Finally
  43.                 conn.Close()
  44.                 conn.Dispose()
  45.             End Try
  46.             Table1.Rows.Add(objRow)
  47.     End Sub

Pero si ya introduzco mas cosas, como la que se ven en el codigo de abajo, se me descuadra todo y el nombre aparece donde tendria que aparece el mes, es decir, en la celda 3.
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 noperario,operario,inicio from cdp_operaciones where noperario = 9152", conn)
  5.         Dim reader As MySqlDataReader
  6.         Dim da As New MySqlDataAdapter(mysql_comando)
  7.         Dim numoperario, longitud1, longitud2, i, j As Integer
  8.         Dim nombre, mes, fechaActual, reglaplantrabajo, mesActual, anoActual, fecha, horas, tprX, tiempotprX,tpr29, tpr30, tpr31 As String
  9.         Dim inicio As Date
  10.         Dim tiempotpr01, tiempotpr02, tiempotpr03, tiempotpr04, tiempotpr05, tiempotpr06, tiempotpr07, tiempotpr08, tiempotpr09, tiempotpr10, tiempotpr11, tiempotpr12, tiempotpr13, tiempotpr14, tiempotpr15, tiempotpr16, tiempotpr17, tiempotpr18, tiempotpr19, tiempotpr20, tiempotpr21, tiempotpr22, tiempotpr23, tiempotpr24, tiempotpr25, tiempotpr26, tiempotpr27, tiempotpr28, tiempotpr29, tiempotpr30, tiempotpr31, tiempoteorico  As Decimal
  11.         Dim valoresarray1, valoresarray2 As String()
  12.         Dim objRow As New TableRow()
  13.         Dim objCell1, objCell2, objCell3, objCell4, objCell5, objCell6, objCell7, objCell8 As New TableCell()
  14.  
  15.         fechaActual = Now.Date
  16.         mesActual = Month(fechaActual)
  17.         anoActual = Year(fechaActual)
  18.         fecha = mesActual + "/" + anoActual
  19.         i = 0
  20.         j = 0
  21.         tiempoteorico = 0
  22.  
  23.         valoresarray1 = calculoFechaHorasReales(numoperario, fechaActual)
  24.         longitud1 = valoresarray1.Length
  25.         reglaplantrabajo = calculoReglaPlanTrabajo(numoperario, fechaActual)
  26.         valoresarray2 = calculoPeriodosTrabajo(reglaplantrabajo, fechaActual)
  27.         longitud2 = valoresarray2.Length
  28.  
  29.         For i = 0 To longitud1 - 1
  30.             Try
  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.                             inicio = reader.GetValue(2)
  40.                             objCell1.Controls.Add(New LiteralControl(numoperario))
  41.                             objCell2.Controls.Add(New LiteralControl(nombre))
  42.                             objCell3.Controls.Add(New LiteralControl(mes))
  43.                             objCell4.Controls.Add(New LiteralControl(inicio))
  44.                             objRow.Cells.Add(objCell1)
  45.                             objRow.Cells.Add(objCell2)
  46.                             objRow.Cells.Add(objCell3)
  47.                             objRow.Cells.Add(objCell4)
  48.                         End While
  49.                         .Dispose()
  50.                     End With
  51.  
  52.                     objCell5.Controls.Add(New LiteralControl("Capturadas"))
  53.                     objRow.Cells.Add(objCell5) 'porcentaje horas capturas
  54.                     horas = calcularHorasDia(valoresarray1(i))
  55.                     objCell6.Controls.Add(New LiteralControl(horas))
  56.                     objRow.Cells.Add(objCell6)
  57.                     objCell7.Controls.Add(New LiteralControl("%"))
  58.                     objRow.Cells.Add(objCell7) 'porcentaje horas reales
  59.  
  60.                     tpr29 = valoresarray2(28)
  61.                     tpr30 = valoresarray2(29)
  62.                     tpr31 = valoresarray2(30)
  63.                     tiempotpr01 = calcularTiempoTeoricoDia(valoresarray2(0))
  64.                     tiempotpr02 = calcularTiempoTeoricoDia(valoresarray2(1))
  65.                     tiempotpr03 = calcularTiempoTeoricoDia(valoresarray2(2))
  66.                     tiempotpr04 = calcularTiempoTeoricoDia(valoresarray2(3))
  67.                     tiempotpr05 = calcularTiempoTeoricoDia(valoresarray2(4))
  68.                     tiempotpr06 = calcularTiempoTeoricoDia(valoresarray2(5))
  69.                     tiempotpr07 = calcularTiempoTeoricoDia(valoresarray2(6))
  70.                     tiempotpr08 = calcularTiempoTeoricoDia(valoresarray2(7))
  71.                     tiempotpr09 = calcularTiempoTeoricoDia(valoresarray2(8))
  72.                     tiempotpr10 = calcularTiempoTeoricoDia(valoresarray2(9))
  73.                     tiempotpr11 = calcularTiempoTeoricoDia(valoresarray2(10))
  74.                     tiempotpr12 = calcularTiempoTeoricoDia(valoresarray2(11))
  75.                     tiempotpr13 = calcularTiempoTeoricoDia(valoresarray2(12))
  76.                     tiempotpr14 = calcularTiempoTeoricoDia(valoresarray2(13))
  77.                     tiempotpr15 = calcularTiempoTeoricoDia(valoresarray2(14))
  78.                     tiempotpr16 = calcularTiempoTeoricoDia(valoresarray2(15))
  79.                     tiempotpr17 = calcularTiempoTeoricoDia(valoresarray2(16))
  80.                     tiempotpr18 = calcularTiempoTeoricoDia(valoresarray2(17))
  81.                     tiempotpr19 = calcularTiempoTeoricoDia(valoresarray2(18))
  82.                     tiempotpr20 = calcularTiempoTeoricoDia(valoresarray2(19))
  83.                     tiempotpr21 = calcularTiempoTeoricoDia(valoresarray2(20))
  84.                     tiempotpr22 = calcularTiempoTeoricoDia(valoresarray2(21))
  85.                     tiempotpr23 = calcularTiempoTeoricoDia(valoresarray2(22))
  86.                     tiempotpr24 = calcularTiempoTeoricoDia(valoresarray2(23))
  87.                     tiempotpr25 = calcularTiempoTeoricoDia(valoresarray2(24))
  88.                     tiempotpr26 = calcularTiempoTeoricoDia(valoresarray2(25))
  89.                     tiempotpr27 = calcularTiempoTeoricoDia(valoresarray2(26))
  90.                     tiempotpr28 = calcularTiempoTeoricoDia(valoresarray2(27))
  91.                     If tpr29 <> " " Then
  92.                         tiempotpr29 = calcularTiempoTeoricoDia(valoresarray2(28))
  93.                     End If
  94.                     If tpr30 <> " " Then
  95.                         tiempotpr30 = calcularTiempoTeoricoDia(valoresarray2(29))
  96.                     End If
  97.                     If tpr31 <> " " Then
  98.                         tiempotpr31 = calcularTiempoTeoricoDia(valoresarray2(30))
  99.                     End If
  100.  
  101.                     tiempoteorico = tiempotpr01 + tiempotpr02 + tiempotpr03 +    tiempotpr04 + tiempotpr05 + tiempotpr06 + tiempotpr07 + tiempotpr08 + tiempotpr09 + tiempotpr10 + tiempotpr11 + tiempotpr12 + tiempotpr13 + tiempotpr14 + tiempotpr15 + tiempotpr16 + tiempotpr17 + tiempotpr18 + tiempotpr19 + tiempotpr20 + tiempotpr21 + tiempotpr22 + tiempotpr23 + tiempotpr24 + tiempotpr25 + tiempotpr26 + tiempotpr27 + tiempotpr28 + tiempotpr29 + tiempotpr30 + tiempotpr31
  102.                     objCell8.Controls.Add(New LiteralControl("tiempoteorico"))
  103.                     objRow.Cells.Add(objCell8) 'horas teoricas
  104.                 End Using
  105.             Catch ex As Exception
  106.                 MsgBox("Error en BD" & Chr(13) & Chr(13) & ex.Message)
  107.             Finally
  108.                 conn.Close()
  109.                 conn.Dispose()
  110.             End Try
  111.             Table1.Rows.Add(objRow)
  112.         Next
  113.     End Sub

Alguien me puede echar una mano?
__________________
Gracias por todo;

Un saludo