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
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim conn As New MySqlConnection conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("conexionMySQL").ConnectionString Dim mysql_comando As New MySqlCommand("Select noperario,operario,inicio from cdp_operaciones where noperario = 9152", conn) Dim reader As MySqlDataReader Dim da As New MySqlDataAdapter(mysql_comando) Dim numoperario As Integer Dim nombre, mes, fechaActual, reglaplantrabajo, mesActual, anoActual, fecha, horas As String Dim inicio As Date Dim objRow As New TableRow() Dim objCell1, objCell2, objCell3, objCell4, objCell5, objCell6, objCell7, objCell8 As New TableCell() fechaActual = Now.Date fecha = mesActual + "/" + anoActual Try Using conn conn.Open() With mysql_comando reader = .ExecuteReader() While reader.Read() numoperario = reader.GetValue(0) nombre = reader.GetValue(1) mes = fecha inicio = reader.GetValue(2) objCell1.Controls.Add(New LiteralControl(numoperario)) objCell2.Controls.Add(New LiteralControl(nombre)) objCell3.Controls.Add(New LiteralControl(mes)) objCell4.Controls.Add(New LiteralControl(inicio)) objRow.Cells.Add(objCell1) objRow.Cells.Add(objCell2) objRow.Cells.Add(objCell3) objRow.Cells.Add(objCell4) End While .Dispose() End With End Using Catch ex As Exception Finally conn.Dispose() End Try Table1.Rows.Add(objRow) 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
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim conn As New MySqlConnection conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("conexionMySQL").ConnectionString Dim mysql_comando As New MySqlCommand("Select noperario,operario,inicio from cdp_operaciones where noperario = 9152", conn) Dim reader As MySqlDataReader Dim da As New MySqlDataAdapter(mysql_comando) Dim numoperario, longitud1, longitud2, i, j As Integer Dim nombre, mes, fechaActual, reglaplantrabajo, mesActual, anoActual, fecha, horas, tprX, tiempotprX,tpr29, tpr30, tpr31 As String Dim inicio As Date 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 Dim valoresarray1, valoresarray2 As String() Dim objRow As New TableRow() Dim objCell1, objCell2, objCell3, objCell4, objCell5, objCell6, objCell7, objCell8 As New TableCell() fechaActual = Now.Date fecha = mesActual + "/" + anoActual i = 0 j = 0 tiempoteorico = 0 valoresarray1 = calculoFechaHorasReales(numoperario, fechaActual) longitud1 = valoresarray1.Length reglaplantrabajo = calculoReglaPlanTrabajo(numoperario, fechaActual) valoresarray2 = calculoPeriodosTrabajo(reglaplantrabajo, fechaActual) longitud2 = valoresarray2.Length For i = 0 To longitud1 - 1 Try Using conn conn.Open() With mysql_comando reader = .ExecuteReader() While reader.Read() numoperario = reader.GetValue(0) nombre = reader.GetValue(1) mes = fecha inicio = reader.GetValue(2) objCell1.Controls.Add(New LiteralControl(numoperario)) objCell2.Controls.Add(New LiteralControl(nombre)) objCell3.Controls.Add(New LiteralControl(mes)) objCell4.Controls.Add(New LiteralControl(inicio)) objRow.Cells.Add(objCell1) objRow.Cells.Add(objCell2) objRow.Cells.Add(objCell3) objRow.Cells.Add(objCell4) End While .Dispose() End With objCell5.Controls.Add(New LiteralControl("Capturadas")) objRow.Cells.Add(objCell5) 'porcentaje horas capturas horas = calcularHorasDia(valoresarray1(i)) objCell6.Controls.Add(New LiteralControl(horas)) objRow.Cells.Add(objCell6) objCell7.Controls.Add(New LiteralControl("%")) objRow.Cells.Add(objCell7) 'porcentaje horas reales tpr29 = valoresarray2(28) tpr30 = valoresarray2(29) tpr31 = valoresarray2(30) tiempotpr01 = calcularTiempoTeoricoDia(valoresarray2(0)) tiempotpr02 = calcularTiempoTeoricoDia(valoresarray2(1)) tiempotpr03 = calcularTiempoTeoricoDia(valoresarray2(2)) tiempotpr04 = calcularTiempoTeoricoDia(valoresarray2(3)) tiempotpr05 = calcularTiempoTeoricoDia(valoresarray2(4)) tiempotpr06 = calcularTiempoTeoricoDia(valoresarray2(5)) tiempotpr07 = calcularTiempoTeoricoDia(valoresarray2(6)) tiempotpr08 = calcularTiempoTeoricoDia(valoresarray2(7)) tiempotpr09 = calcularTiempoTeoricoDia(valoresarray2(8)) tiempotpr10 = calcularTiempoTeoricoDia(valoresarray2(9)) tiempotpr11 = calcularTiempoTeoricoDia(valoresarray2(10)) tiempotpr12 = calcularTiempoTeoricoDia(valoresarray2(11)) tiempotpr13 = calcularTiempoTeoricoDia(valoresarray2(12)) tiempotpr14 = calcularTiempoTeoricoDia(valoresarray2(13)) tiempotpr15 = calcularTiempoTeoricoDia(valoresarray2(14)) tiempotpr16 = calcularTiempoTeoricoDia(valoresarray2(15)) tiempotpr17 = calcularTiempoTeoricoDia(valoresarray2(16)) tiempotpr18 = calcularTiempoTeoricoDia(valoresarray2(17)) tiempotpr19 = calcularTiempoTeoricoDia(valoresarray2(18)) tiempotpr20 = calcularTiempoTeoricoDia(valoresarray2(19)) tiempotpr21 = calcularTiempoTeoricoDia(valoresarray2(20)) tiempotpr22 = calcularTiempoTeoricoDia(valoresarray2(21)) tiempotpr23 = calcularTiempoTeoricoDia(valoresarray2(22)) tiempotpr24 = calcularTiempoTeoricoDia(valoresarray2(23)) tiempotpr25 = calcularTiempoTeoricoDia(valoresarray2(24)) tiempotpr26 = calcularTiempoTeoricoDia(valoresarray2(25)) tiempotpr27 = calcularTiempoTeoricoDia(valoresarray2(26)) tiempotpr28 = calcularTiempoTeoricoDia(valoresarray2(27)) If tpr29 <> " " Then tiempotpr29 = calcularTiempoTeoricoDia(valoresarray2(28)) End If If tpr30 <> " " Then tiempotpr30 = calcularTiempoTeoricoDia(valoresarray2(29)) End If If tpr31 <> " " Then tiempotpr31 = calcularTiempoTeoricoDia(valoresarray2(30)) End If 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 objCell8.Controls.Add(New LiteralControl("tiempoteorico")) objRow.Cells.Add(objCell8) 'horas teoricas End Using Catch ex As Exception Finally conn.Dispose() End Try Table1.Rows.Add(objRow) Next End Sub
Alguien me puede echar una mano?